DATPen/DATPenSet¶
-
class
DATPen(**kwargs)¶ -
addSmoothPoints(length=100)¶ WIP
-
attr(tag='default', field=None, **kwargs)¶ Set a style attribute on the pen.
-
bounds()¶ Calculate the bounds of this shape; mostly for internal use.
-
catmull(points, close=False)¶ Run a catmull spline through a series of points
-
clearAttrs()¶ Remove all styling.
-
closePath()¶ The standard RecordingPen.closePath, but returns self for chainability.
-
curveTo(*points)¶ The standard RecordingPen.curveTo, but returns self for chainability.
-
difference(otherPen)¶ Calculate and return the difference of this shape and another.
-
dots(radius=4)¶ (Necessary?) Create circles at moveTo commands
-
endPath()¶ The standard RecordingPen.endPath, but returns self for chainability.
-
explode(into_set=False)¶ Read each contour into its own DATPen (or DATPenSet if into_set is True); returns a DATPenSet
-
flatpoints()¶ Returns a flat list of points from the DATPen’s original contours; does not modify the DATPen
-
flatten(length=10)¶ Runs a fontTools FlattenPen on this pen
-
getFrame(th=False, tv=False)¶ For internal use; creates a frame based on calculated bounds.
-
glyph(glyph)¶ Play a glyph (like from defcon) into this pen.
-
gridlines(rect, x=20, y=None)¶ Construct a grid in the pen using x and (optionally) y subdivisions
-
hull(points)¶ Same as DATPen.line but calls closePath instead of endPath`
-
intersection(otherPen)¶ Calculate and return the intersection of this shape and another.
-
length(t=1)¶ Get the length of the curve for time t
-
line(points)¶ Syntactic sugar for moveTo`+`lineTo`(…)+`endPath; can have any number of points
-
lineTo(p1)¶ The standard RecordingPen.lineTo, but returns self for chainability.
-
lines()¶ Returns lines connecting point-representation of flatpoints
-
moveTo(p0)¶ The standard RecordingPen.moveTo, but returns self for chainability.
-
openAndClosed()¶ Explode and then classify group each contour into open/closed pens; (what is this good for?)
-
outline(offset=1, drawInner=True, drawOuter=True, cap='square')¶ AKA expandStroke
-
oval(rect)¶ Oval primitive
-
pattern(rect, clip=False)¶ WIP — maybe not long for this earth
-
pixellate(rect, increment=50, inset=0)¶ WIP
-
point_t(t=0.5)¶ Get point value for time t
-
points()¶ Returns a list of points grouped by contour from the DATPen’s original contours; useful for drawing bezier skeletons; does not modify the DATPen
-
polygon(sides, rect)¶ Polygon primitive; WIP
-
qCurveTo(*points)¶ The standard RecordingPen.qCurveTo, but returns self for chainability.
-
quadratic(a, b, c, lineTo=False)¶ WIP
-
record(pen)¶ Play a pen into this pen, meaning that pen will be added to this one’s value.
-
rect(rect, *args)¶ Rectangle primitive — moveTo/lineTo/lineTo/lineTo/closePath
-
removeOverlap()¶ Remove overlaps within this shape and return itself.
-
reverse()¶ Reverse the winding direction of the pen.
-
reverseDifference(otherPen)¶ Calculate and return the reverseDifference of this shape and another.
-
roughen(amplitude=10, threshold=10)¶ Randomizes points in skeleton
-
round(rounding)¶ Round the values of this pen to integer values.
-
roundedRect(rect, hr, vr)¶ Rounded rectangle primitive
-
scanlines(rect, sample=40, width=20, threshold=10)¶ WIP
-
semicircle(r, center, fext=0.5, rext=0.5)¶ Not really a semicircle fext controls extension from the standard on the “flat” edge rext controls extension from the standard on the “round” edge
-
simplify()¶ DO NOT USE
-
sine(r, periods)¶ Sine-wave primitive
-
skeleton(scale=1, returnSet=False)¶ Vector-editing visualization
-
skeletonPoints()¶ WIP
-
smooth()¶ Runs a catmull spline on the datpen, useful in combination as flatten+roughen+smooth
-
standingwave(r, periods, direction=1)¶ Standing-wave primitive
-
subsegment(start=0, end=1)¶ Return a subsegment of the pen based on t values start and end
-
svg(file, gid, rect=Rect([0, 0, 0, 100]))¶ WIP; attempt to read an svg file into the pen
-
to_glyph(name=None, width=None)¶ Create a glyph (like from defcon) using this pen’s value. Warning: be sure to call endPath or closePath on your pen or this call will silently do nothing
-
transform(transform, transformFrame=True)¶ Perform an arbitrary transformation on the pen, using the fontTools Transform class.
-
union(otherPen)¶ Calculate and return the union of this shape and another.
-
xor(otherPen)¶ Calculate and return the XOR of this shape and another.
-
-
class
DATPenSet(pens=[])¶ A set/collection of DATPen’s; behaves like a list
-
addFrame(frame, typographic=False, passthru=False)¶ Add a frame that isn’t derived from the bounds
-
bounds()¶ Calculated bounds of a DATPenSet
-
cast(_class, *args)¶ Quickly cast to a (different) subclass.
-
clearFrame()¶ Remove the DATPen frame.
-
clearFrames()¶ Get rid of any non-bounds-derived pen frames; i.e. frames set by Harfbuzz
-
collapse(levels=100, onself=False)¶ AKA flatten in some programming contexts, though flatten is a totally different function here that flattens outlines; this function flattens nested collections into one-dimensional collections
-
contain(rect)¶ For conveniently marking an arbitrary Rect container.
-
copy(with_data=False)¶ Get a completely new copy of this whole set of pens, usually done so you can duplicate and further modify a DATPenSet without mutating the original
-
f(*value)¶ Get/set a (f)ill
-
ffg(glyph_name)¶ (f)ind the (f)irst (g)lyph named this name
-
fft(tag)¶ (f)ind the (f)irst (t)agged with tag
-
fill(*value)¶ Get/set a (f)ill
-
filmjitter(doneness, base=0, speed=10, 20, scale=2, 3, octaves=16)¶ An easy way to make something move in a way reminiscent of misregistered film
-
filter(fn: Callable[[int, coldtype.pens.datpen.DATPen], bool])¶ Filter top-level pen(s)
-
flatten(levels=100, onself=False)¶ AKA flatten in some programming contexts, though flatten is a totally different function here that flattens outlines; this function flattens nested collections into one-dimensional collections
-
frameSet(th=False, tv=False)¶ All the frames of all the pens
-
getFrame(th=False, tv=False)¶ Get the frame of the DATPenSet; th means (t)rue (h)orizontal; ty means (t)rue (v)ertical; passing either ignores a non-bounds-derived frame in either dimension
-
getTag()¶ Retrieve the tag (could probably be a real property)
-
glyphs_named(glyph_name)¶ Pluck glyphs named glyph_name
-
image(src=None, rect=Rect([0, 0, 500, 500]), pattern=True, opacity=1.0)¶ Get/set an image fill
-
img(src=None, rect=Rect([0, 0, 500, 500]), pattern=True, opacity=1.0)¶ Get/set an image fill
-
indexed_subset(indices)¶ Take only the pens at the given indices
-
interleave(style_fn, direction=- 1, recursive=True)¶ Provide a callback-lambda to interleave new DATPens between the existing ones; useful for stroke-ing glyphs, since the stroked glyphs can be placed behind the primary filled glyphs.
-
map(fn: Callable[[int, coldtype.pens.datpen.DATPen], Optional[coldtype.pens.datpen.DATPen]])¶ Apply fn to all top-level pen(s) in this set; if fn returns a value, it will overwrite the pen it was given as an argument; fn lambda receives idx, p as arguments
-
mfilter(fn)¶ Same as filter but (m)utates this DATPenSet to now have only the filtered pens
-
mmap(fn: Callable[[int, coldtype.pens.datpen.DATPen], None])¶ Apply fn to all top-level pen(s) in this set but do not look at return value; first m in mmap stands for mutate; fn lambda receives idx, p as arguments
-
noop(*args, **kwargs)¶ Does nothing
-
pen()¶ A flat representation of this set as a single pen
-
pfilter(fn)¶ Filter all pens, recursively
-
pmap(fn)¶ Apply fn to all individal pens, recursively
-
print_tree(depth=0)¶ Print a hierarchical representation of the pen set
-
removeBlanks()¶ Remove blank pens from the set
-
reversePens()¶ Reverse the order of the pens; useful for overlapping glyphs from the left-to-right rather than right-to-left (as is common in OpenType applications)
-
rotate(degrees, point=None)¶ Rotate this shape by a degree (in 360-scale, counterclockwise).
-
round(rounding)¶ Round all values for all pens in this set
-
rp()¶ Reverse the order of the pens; useful for overlapping glyphs from the left-to-right rather than right-to-left (as is common in OpenType applications)
-
s(*value)¶ Get/set a (s)troke
-
scale(scaleX, scaleY=None, center=None)¶ Scale this shape by a percentage amount (1-scale).
-
scaleToHeight(h)¶ Scale this shape horizontally
-
scaleToRect(rect, preserveAspect=True)¶ Scale this shape into a Rect.
-
scaleToWidth(w)¶ Scale this shape horizontally
-
stroke(*value)¶ Get/set a (s)troke
-
strokeWidth(value)¶ Get/set a (s)troke (w)idth
-
sw(value)¶ Get/set a (s)troke (w)idth
-
tag(tag)¶ For conveniently marking a DATPen(Set) w/o having to put it into some other data structure.
-
tagged(tag)¶ Yield all top-level pens tagged w/ tag
-
trackToRect(rect, pullToEdges=False, r=0)¶ Distribute pens evenly within a frame
-
translate(x, y=None, transformFrame=True)¶ Translate this shape by x and y (pixel values).
-