21.3 Drawing other objects on canvas

The objects of canvas.T class and its subclasses provides several methods that can be invoked manually to draw variety of things if you desire so. These methods take Postscript points as the unit of X and Y coordinates, as described in Section 4. (These methods obey the scaling-factor specifications).

line( linestyle, x1, y1, x2, y2)

# draw a line segment from (10,20) to (100, 200)
can.line(line_style.blackdash1, 10, 20, 100, 200)

polygon( linestyle, fillstyle, [(x1,y1), ..., (xn, yn)], shadow = None)

Draw a polygon points, with linestyle ( see Section 14), and fill with fillstyle (see Section 16). Parameter points is a list of coordinates, e.g., ((10,10), (15,5), (20,8)). Value of linestyle can be None, in which case no line is drawn on the perimeter. Value of fillstyle can also be None, in which the internal of the polygon are left undrawn. Parameter shadow is either None or tuple (xdelta, ydelta, shadowstyle). If non-None, a shadow of shadowstyle (see Section 16) is drawn beneath the polygon at the offset (xdelta, ydelta).

can.polygon(line_style.default, fill_style.default,
               [(10, 20), (100, 200), (300,300)])

rectangle( linestyle, fillstyle, x1, y1, x2, y2, shadow=None)

Parameter shadow is either None or tuple (xdelta, ydelta, shadowstyle). If non-None, a shadow of shadowstyle ( see Section 16) is drawn beneath the polygon at the offset (xdelta, ydelta).

can.rectangle(line_style.default, fill_style.default, 10, 20, 300, 300)
ellipsis( linestyle, fillstyle, x, y, radius, y_elongation=1, start=0, end=360, shadow=None)

The start and end angles are specified in degrees; i.e., between 0 and 360. Parameter shadow is either None or tuple (xdelta, ydelta, shadowstyle). If non-None, a shadow of shadowstyle ( see Section 16) is drawn beneath the polygon at the offset (xdelta, ydelta).

round_rectangle( linestyle, fillstyle, x1, y2, x2, y2, radius, shadow=None)
Draw a rectangle with rounded four corners. Parameter radius specifies the radius of each corner.

Parameter shadow is either None or tuple (xdelta, ydelta, shadowstyle). If non-None, a shadow of shadowstyle ( see Section 16) is drawn beneath the polygon at the offset (xdelta, ydelta).

curve( linestyle, [(x1,y2), ..., (xn, yn)])
Draw a Bezier curve.
show( x, y, text)
Draw a text on the canvas at location (x, y). Parameter text supports font manipulation, as described in See Section 17.

verbatim( string)
This procedure outputs an arbitrary string to the output file.