RContour

../_images/RContour.gif

Usage

# robofab manual
# Contour object
# usage examples

# 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 of 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.

Note

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 Point‘s.

bPoints

The contour as a list of bPoint‘s.

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

# robofab manual
# Contour object
# method examples

links