RoboFab RContour
Usage
# take a glyph (one with outlines obviously) c = CurrentGlyph() # get to contours by index: print c[0] >>> < RContour for Mailer-Regular.a[0] >
Description
RContour is an object for, well, contours. A contour is a single path of any number of points and shape. A glyph usually consists of a couple fo contours, and this the object that represents each one. The RContour object offers access to the outline matter in various ways. The parent of RContour is usually RGlyph.
Understanding Contours and outlines
The way outline data is organised in RoboFab, and how the various objects relate is described here: understanding contours.
If you want to add new contours to a glyph it's easier to draw them with a pen than to construct the shapes from segments.
Attributes
- index: the index of the contour in the Glyph.
- selected: returns 1 if the contour is selected, 0 if it isn't.
- box: the bounding box for the contour (read only).
- clockwise: direction of contour: 1=clockwise 0=counterclockwise
- points: the contour as a list of Points.
- bPoints: the contour as a list of bPoints.
Attribute examples
Examples with contours and points here.
Methods for segments
For regular drawing in glyphs: please use Pens. If you want to mess with segments on a lower level, be our guest:
- appendSegment(segmentType, points, smooth=False): add a segment to the contour. Parameters?
- insertSegment(index, segmentType, points, smooth=False): insert a segment into the contour.
- removeSegment(index): remove a segment from the contour.
- setStartSegment(segmentIndex): set the first node on the contour.
Methods for points
- appendBPoint(pointType, anchor, bcpIn=(0, 0), bcpOut=(0, 0)): append a bPoint to the contour.
- autoStartSegment(): automatically set the lower left point of the contour as the first point.
- insertBPoint(index, pointType, anchor, bcpIn=(0, 0), bcpOut=(0, 0)): insert a bPoint at index on the contour.
Other methods
- reverseContour(): reverse contour direction.
- copy(): duplicate this contour.
- draw(aPen): draw the object with a RoboFab segment pen.
- drawPoints(aPen): draw the object with a point pen.
- move((x, y)): move the contour.
- pointInside((x, y), evenOdd=0): determine if the point is inside or ouside of the contour.
- round(): round the value of all points in the contour.
- scale((x, y), center=(0, 0)): Scale the contour by x and y. Optionally set the center of the scale.
- rotate(angle, offset=None): Rotate the contour by angle (in degrees). Optionally set an offset value.
- skew(angle, offset=None): Skew the contour by angle (in degrees). Optionally set an offset value.
- transform(matrix): transform this contour. Use a Transform matrix object to mess with the contour. See also how to use transformations.
Method examples
#method examples