mojo.drawingTools

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

Add an arc with the given center and radius, from startAngle to endAngle, going clockwise if clockwise is True and counter-clockwise if clockwise is False.

closePath()

Close the current path.

curveTo(h1, h2, pt)

Add a curve segment to a given point (x,y) with bezier handles at (h1x,h1y) and (h2x,h2y).

dashLine(*args)

Deprecated. Use lineDash() instead.

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 from red, green, blue and alpha values. Each argument must be a float between 0 and 1.

font(fontName, fontSize=None)

Set a font with the given PostScript font name.

Optionally, a fontSize can be set directly.

The default font, which is also used as fallback font, is LucidaGrande.

The default fontSize is 10pt.

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 the given (x,y) position and alpha value. Common file types such as pdf, jpg, png, tiff and gif are supported.

Optionally, an alpha transparency can be provided as 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)

Sets the line cap mode.

Possible values: butt, square and round.

lineDash(*arg)

Sets a line dash with any given amount of lenghts. Uneven lenghts define the visible parts of the stroke, even lenghts the invisible.

lineHeight(value)

Set the line height in points.

lineJoin(join)

Sets the line join mode.

Possible values: miter, round and bevel.

lineTo(pt)

Add a line segment to a given point (x,y).

miterLimit(value)

Sets a miter limit. Used on corner points.

moveTo(pt)

Move to a point (x,y) to start a new contour.

newPath()

Create a new bezier path.

oval(x, y, width, height)

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

polygon(xy, *args, **kwargs)

Draws a polygon by connecting the points in a given list. Optionally, a close argument (bool) can be provided to close or open the path.

By default, a polygon is a closed path.

rect(x, y, width, height)

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

restore()

Restore to the saved canvas state.

rotate(angle, center=None)

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

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

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

save()

Save the current state of the canvas.

savedState()

Save and restore the current graphics state in a with statement.

scale(x=1, y=None)

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

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

skew(angle1, angle2=0)

Skew the canvas with the given angles angle1 and angle2, in degrees.

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

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

Sets the stroke color from red, green, blue and alpha values. Each argument must be a float between 0 and 1.

strokeWidth(value)

Sets the stroke width.

text(txt, x, y=None)

Draw a text at a given (x,y) position.

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

Draw a text into a given rectangular area.

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

Optionally, a text 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 given text with the current settings (such as font, fontSize and lineHeight) as a tuple of (width,height).

transform(transform, center=(0, 0))

Transform the canvas with a given transformation matrix.

translate(x=0, y=0)

Translate the canvas with a given x (horizontal) and y (vertical) offset.

Last edited on 14/01/2020