Path

class shoebot.data.BezierPath(bot, path=None, fill=None, fillrule=None, stroke=None, strokewidth=0, strokecap=None, strokejoin=None, strokedash=None, dashoffset=None, blendmode=None, packed_elements=None)

Represents a Bezier path as a list of PathElements.

Shoebot implementation of Nodebox’s BezierPath wrapper. While Nodebox relies on Cocoa/QT for its data structures, this is more of an “agnostic” implementation that won’t require any other back-ends to do some simple work with paths.

(this last sentence is not so correct: we use a bit of Cairo for getting path dimensions)

append(*args)
addpoint(*args)
copy()
moveto(x, y)
relmoveto(x, y)
lineto(x, y)
rellineto(x, y)
line(x1, y1, x2, y2)
curveto(x1, y1, x2, y2, x3, y3)
relcurveto(x1, y1, x2, y2, x3, y3)
arc(x, y, radius, angle1, angle2)
closepath()
ellipse(x, y, w, h, ellipsemode='corner')
rect(x, y, w, h, roundness=0.0, rectmode='corner')
contains(x, y)

Return cached bounds of this Grob. If bounds are not cached, render to a meta surface, and keep the meta surface and bounds cached.

property center

Return cached bounds of this Grob. If bounds are not cached, render to a meta surface, and keep the meta surface and bounds cached.

draw()
point(t, segments=None)

Returns the PathElement at time t (0.0-1.0) on the path.

Returns coordinates for point at t on the path. Gets the length of the path, based on the length of each curve and line in the path. Determines in what segment t falls. Gets the point on that segment. When you supply the list of segment lengths yourself, as returned from length(path, segmented=True), point() works about thirty times faster in a for-loop since it doesn’t need to recalculate the length during each iteration.

points(amount=100, start=0.0, end=1.0, segments=None)

Returns an iterator with a list of calculated points for the path. To omit the last point on closed paths: end=1-1.0/amount

extend(pathelements)
property bounds

Return cached bounds of this Grob. If bounds are not cached, render to a meta surface, and keep the meta surface and bounds cached.

property contours

Returns a list of contours in the path, as BezierPath objects. A contour is a sequence of lines and curves separated from the next contour by a MOVETO. For example, the glyph “o” has two contours: the inner circle and the outer circle.

property length

Returns the length of the path. Calculates the length of each spline in the path, using n as a number of points to measure. When segmented is True, returns a list containing the individual length of each spline as values between 0.0 and 1.0, defining the relative length of each spline in relation to the total path length.

property fill
inheritFromContext(ignore=())

Doesn’t store exactly the same items as Nodebox for ease of implementation, it has enough to get the Nodebox Dentrite example working.

property stroke
property strokewidth