Drawing Paths

Using bezier paths.

drawBot.newPath()

Create a new path.

drawBot.moveTo((x, y))

Move to a point x, y.

drawBot.lineTo((x, y))

Line to a point x, y.

drawBot.curveTo((x1, y1), (x2, y2), (x3, y3))

Curve to a point x3, y3. With given bezier handles x1, y1 and x2, y2.

drawBot.arcTo((x1, y1), (x2, y2), radius)

Arc from one point to an other point with a given radius.

drawBot.closePath()

Close the path.

drawBot.drawPath(path=None)

Draw the current path, or draw the provided path.

# create a new empty path
newPath()
# set the first oncurve point
moveTo((100, 100))
# line to from the previous point to a new point
lineTo((100, 200))
lineTo((200, 200))

# curve to a point with two given handles
curveTo((200, 100), (150, 100), (100, 100))

# close the path
closePath()
# draw the path
drawPath()
drawBot.clipPath(path=None)

Use the current path as a clipping path. The clipping path will be used until the canvas gets a restore().

# create a bezier path
path = BezierPath()

# move to a point
path.moveTo((100, 100))
# line to a point
path.lineTo((100, 200))
path.lineTo((200, 200))
# close the path
path.closePath()
# set the path as a clipping path
clipPath(path)
# the oval will be clipped inside the path
oval(100, 100, 100, 100)