BezierPath

drawBot.BezierPath()

Return a BezierPath object. This is a reusable object, if you want to draw the same over and over again.

BezierPath methods

bezierPath.moveTo((x, y))

Move to a point x, y.

bezierPath.lineTo((x, y))

Line to a point x, y.

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

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

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

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

bezierPath.closePath()

Close the path.

bezierPath.rect(x, y, w, h)

Add a rectangle at possition x, y with a size of w, h

bezierPath.oval(x, y, w, h)

Add a oval at possition x, y with a size of w, h

bezierPath.text(txt, font=None, fontSize=10, offset=None)

Draws a text with a font and fontSize at an offset in the bezier path.

bezierPath.pointInside((x, y))

Check if a point x, y is inside a path.

bezierPath.bounds()

Return the bounding box of the path as x, y, width, height.

bezierPath.controlPointBounds()

Return the bounding box of the path including the offcurve points as x, y, width, height.

bezierPath.copy()

Copy the bezier path.


BezierPath attributes

bezierPath.points

Return a list of all points.

bezierPath.onCurvePoints

Return a list of all on-curve points.

bezierPath.offCurvePoints

Return a list of all off-curve points.

bezierPath.contours

Return a list of contours with all point coordinates sorted in segments.

# 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()

# loop over a range of 10
for i in range(10):
    # set a random color with alpha value of .3
    fill(random(), random(), random(), .3)
    # in each loop draw the path
    drawPath(path)
    # translate the canvas
    translate(5, 5)

path.text("Hello world", font="Helvetica", fontSize=30, offset=(210, 210))

print "All Points:"
print path.points

print "On Curve Points:"
print path.onCurvePoints

print "Off Curve Points:"
print path.offCurvePoints

# print out all points from all segments in all contours
for contour in path.contours:
    for segment in contour:
        for x, y in segment:
            print x, y