Package Things :: Module BoxOfTricks :: Class DrawLang
[frames] | no frames]

Class DrawLang

object --+
         |
        DrawLang

Use this to generate stepped-paths with curved corners. It uses a simple 'language' comprised of:

  1. l#: Turn left, with an optional number which is the radius of the corner. A sharp-corner is zero (or leave it blank).
  2. r#: Turn right; same as left, only... it goes right.
  3. f#: Go forward, with a number of units to proceed. The units are not optional.

The initial direction is North. Unless you begin with 'r' or 'l', you will be going forward directly upwards.

To draw a square with round corners: r10 f50 r10 f50 r10 f50 r10 f50 (Of course, you should simply use the RoundRect() class for shapes like that.)

r50 f10 r50 f60 r f110 r f60 : Would draw a square with two big curved corners on top (both of radius 50.) Note from this example that the radius is part of the total width; so 50 + 10 + 50 = 110

Use the setup() method to pass your string in. This will create a list of python-cairo line and arc commands that get drawn when you call draw(ctx).

Instance Methods
 
__init__(self)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
 
setup(self, str)
 
draw(self, ctx, x=0, y=0)

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self)
(Constructor)

 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)