mojo.drawingTools

arc(center, radius, startAngle, endAngle, clockwise)

Arc with center and a given radius, from startAngle to endAngle, going clockwise if clockwise is True and counter clockwise if clockwise is False.

closePath()

Close the path.

curveTo(h1, h2, pt)

Curve to a point x, y. With given bezier handles h1x, h1y and h2x, h2y.

dashLine(*args)

drawGlyph(glyph)

Draw a glyph object.

drawPath(path=None)

Draw the current path, or draw the provided path.

fill(r=None, g=None, b=None, a=1)

Sets the fill color with a red, green, blue and alpha value. Each argument must a value float between 0 and 1.

font(fontName, fontSize=None)

Set a font with the name of the font. Optionally a fontSize can be set directly. The default font, also used as fallback font, is ‘LucidaGrande’. The default fontSize is 10pt.

The name of the font relates to the font’s postscript name.

fontSize(fontSize)

Set the font size in points. The default fontSize is 10pt.

image(pathOrImage, x, y=None, alpha=1)

Add an image from a path with an offset and an alpha value. This should accept most common file types like pdf, jpg, png, tiff and gif.

Optionally an alpha can be provided, which is a value between 0 and 1.

installedFonts()

Returns a list of all installed fonts.

line(pt1, pt2)

Draws a line between two given points.

lineCap(cap)

Set a line cap.

Possible values are butt, square and round.

lineDash(*arg)

Set a line dash with any given amount of lenghts. Uneven lenghts will have a visible stroke, even lenghts will be invisible.

lineHeight(value)

Set the line height.

lineJoin(join)

Set a line join.

Possible values are miter, round and bevel.

lineTo(pt)

Line to a point x, y.

miterLimit(value)

Set a miter limit. Used on corner points.

moveTo(pt)

Move to a point x, y.

newPath()

Create a new path.

oval(x, y, width, height)

Draw an oval with a given x, y, width, height.

polygon(xy, *args, **kwargs)

Draws a polygon with n-amount of points. Optionally a close argument can be provided to open or close the path. As default a polygon is a closed path.

rect(x, y, width, height)

Draw a rectangle with a given x, y, width, height.

restore()

Restore to a saved canvase state.

rotate(angle)

Rotate the canvas around the origin point with a given angle in degrees.

roundedRect(x, y, width, height, radius)

Draw a rounded rectangle with a given given x, y, width, height and radius.

save()

Save the current state of the canvas.

scale(x=1, y=None)

Scale the canvas with a given x (horizontal scale) and y (vertical scale).

If only 1 argument is provided a proportional scale is applied.

skew(angle1, angle2=0)

Skew the canvas with given angle1 and angle2.

If only one argument is provided a proportional skew is applied.

stroke(r=None, g=None, b=None, a=1)

Sets the stroke color with a red, green, blue and alpha value. Each argument must a value float between 0 and 1.

strokeWidth(value)

Sets stroke width.

text(txt, x, y=None)

Draw a text at a provided position.

textBox(txt, xywh, align='left')

Draw a text in a provided rectangle.

A box must be a (x, y, width, height) tuple.

Optionally an alignment can be set. Possible align values are: "left", "center", "right" and "justified".

The default alignment is left.

textSize(txt, align=None)

Returns the size of a text with the current settings, like font, fontSize and lineHeight as a tuple (width, height).

transform(transform)

Transform the canvas with a transformation matrix.

translate(x=0, y=0)

Translate the canvas with a given offset.

Last edited on 13/11/2018