Boolean operations on paths which uses a super fast polygon clipper library by Angus Johnson.
You can download the latest version from PyPI:
https://pypi.org/project/booleanOperations.
Pip is the recommended tool to install booleanOperations.
To install the latest version:
pip install booleanOperationsBooleanOperations depends on the following packages:
All dependencies are available on PyPI, so they will be resolved automatically upon installing booleanOperations.
Containing a BooleanOperationManager handling all boolean operations
on paths. Paths must be similar to defcon, robofab contours. A
manager draws the result in a pointPen.
from booleanOperations import BooleanOperationManager
manager = BooleanOperationManager()Create a BooleanOperationManager.
Performs a union on all contours and draw it in the pointPen.
(this is a what a remove overlaps does)
Knock out the clipContours from the contours and draw it in the
pointPen.
Draw only the overlaps from the contours with the
clipContoursand draw it in the pointPen.
Draw only the parts that not overlaps from the contours with the
clipContoursand draw it in the pointPen.
Returning all intersection for the given contours
A glyph like object with boolean powers.
from booleanOperations.booleanGlyph import BooleanGlyph
booleanGlyph = BooleanGlyph(sourceGlyph)Create a BooleanGlyph object from sourceGlyph. This is a very
shallow glyph object with basic support.
Perform a union with the other. Other must be a glyph or
BooleanGlyph object.
result = BooleanGlyph(glyph).union(BooleanGlyph(glyph2))
result = BooleanGlyph(glyph) | BooleanGlyph(glyph2)Perform a difference with the other. Other must be a glyph or
BooleanGlyph object.
result = BooleanGlyph(glyph).difference(BooleanGlyph(glyph2))
result = BooleanGlyph(glyph) % BooleanGlyph(glyph2)Perform a intersection with the other. Other must be a glyph or
BooleanGlyph object.
result = BooleanGlyph(glyph).intersection(BooleanGlyph(glyph2))
result = BooleanGlyph(glyph) & BooleanGlyph(glyph2)Perform a xor with the other. Other must be a glyph or
BooleanGlyph object.
result = BooleanGlyph(glyph).xor(BooleanGlyph(glyph2))
result = BooleanGlyph(glyph) ^ BooleanGlyph(glyph2)Perform a union on it self. This will remove all overlapping contours and self intersecting contours.
result = BooleanGlyph(glyph).removeOverlap()The name of the sourceGlyph.
The unicodes of the sourceGlyph.
The width of the sourceGlyph.
The lib of the sourceGlyph.
The note of the sourceGlyph.
List the contours of the glyph.
List the components of the glyph.
List the anchors of the glyph.