Point¶
Description¶
Point represents one single point with a particular coordinate in a contour. It is used to access off-curve and on-curve points alike. Its cousin BPoint also provides access to incoming and outgoing bcps. Point is exclusively only one single point.
glyph = CurrentGlyph()
for contour in glyph:
for point in contour.points:
print(point)
Overview¶
Copy¶
Copy the current object into a new object of the same type. |
Parents¶
Get or set the point's parent contour object. |
|
Get the point's parent glyph object. |
|
Get the point's parent layer object. |
|
Get the point's parent font object. |
Identification¶
Get or set the name of the point. |
|
Get the object's unique identifier. |
|
Get the index of the point. |
Coordinate¶
Get or set the x coordinate of the point. |
|
Get or set the y coordinate of the point. |
Type¶
Get or set the point's type. |
|
Get or set the point's smooth state. |
Transformations¶
Transform the object according to the given matrix. |
|
Move the object according to the given coordinates. |
|
Scale the object according to the given values. |
|
Rotate the object by the specified value. |
|
Skew the object by the given value. |
Normalization¶
Round the point's coordinates. |
Environment¶
Return the environment's native object wrapped by the current object. |
|
Tell the environment that something has changed in the object. |
Reference¶
- class fontParts.base.BasePoint(*args: Any, **kwargs: Any)[source]¶
Represent the basis for a point object.
This object is almost always created with
BaseContour.appendPoint, the pen returned byBaseGlyph.getPenor the point pen returned byBaseGlyph.getPointPen.An orphan point can be created like this:
>>> point = RPoint()
Copy¶
- BasePoint.copy() BaseObjectType¶
Copy the current object into a new object of the same type.
The returned object will not have a parent object.
- Returns:
A new
BaseObjectsubclass instance with the same attributes.
Parents¶
- BasePoint.contour: dynamicProperty¶
Get or set the point’s parent contour object.
The value must be a
BaseContourinstance orNone.- Returns:
The
BaseContourinstance containing the point orNone.- Raises:
AssertionError – If attempting to set the contour when it has already been set.
Example:
>>> contour = point.contour
- BasePoint.glyph: dynamicProperty¶
Get the point’s parent glyph object.
This property is read-only.
The value must be a
BaseGlyphinstance orNone.Example:
>>> glyph = point.glyph
- BasePoint.layer: dynamicProperty¶
Get the point’s parent layer object.
This property is read-only.
Example:
>>> layer = point.layer
Identification¶
- BasePoint.name: dynamicProperty¶
Get or set the name of the point.
The value must be a
strorNone.Example:
>>> point.name 'my point' >>> point.name = None
- BasePoint.identifier¶
Get the object’s unique identifier.
This attribute is read-only. Use
IdentifierMixin.getIdentifierto request an identifier if it does not exist.- Returns:
The unique identifier assigned to the object as a
str, orNoneindicating the object has no identifier.
Example
>>> object.identifier 'ILHGJlygfds'
Coordinate¶
Type¶
- BasePoint.type: dynamicProperty¶
Get or set the point’s type.
The value must be a
strcontaining one of the following alternatives:Type
Description
'move''line''curve''qcurve''offcurve'An on-curve move to. An on-curve line to. An on-curve cubic curve to. An on-curve quadratic curve to. An off-curve.
- Returns:
A
strrepresenting the type of the point.
Transformations¶
- BasePoint.transformBy(matrix: list[int | float] | tuple[float, float, float, float, float, float], origin: list[int | float] | tuple[int | float, int | float] | None = None) None¶
Transform the object according to the given matrix.
- Parameters:
matrix – The Transformation Matrix to apply.
origin – The optional point at which the transformation should originate as a:ref:type-coordinate. Defaults to
None, representing an origin of(0, 0).
Example:
>>> obj.transformBy((0.5, 0, 0, 2.0, 10, 0)) >>> obj.transformBy((0.5, 0, 0, 2.0, 10, 0), origin=(500, 500))
- BasePoint.moveBy(value: list[int | float] | tuple[int | float, int | float]) None¶
Move the object according to the given coordinates.
- Parameters:
value – The x and y values to move the object by as a Coordinate.
Example:
>>> obj.moveBy((10, 0))
- BasePoint.scaleBy(value: int | float | list[int | float] | tuple[float, float], origin: list[int | float] | tuple[int | float, int | float] | None = None) None¶
Scale the object according to the given values.
- Parameters:
Example:
>>> obj.scaleBy(2.0) >>> obj.scaleBy((0.5, 2.0), origin=(500, 500))
- BasePoint.rotateBy(value: int | float, origin: list[int | float] | tuple[int | float, int | float] | None = None) None¶
Rotate the object by the specified value.
- Parameters:
value – The angle at which to rotate the object as an
intor afloat.origin – The optional point at which the rotation should originate as a Coordinate. Defaults to
None, representing an origin of(0, 0).
Example:
>>> obj.rotateBy(45) >>> obj.rotateBy(45, origin=(500, 500))
- BasePoint.skewBy(value: int | float | list[int | float] | tuple[float, float], origin: list[int | float] | tuple[int | float, int | float] | None = None) None¶
Skew the object by the given value.
- Parameters:
value – The value by which to skew the object as either a single
intorfloatcorresponding to the x direction, or atupleof twointorfloatvalues corresponding to the x and y directions.origin – The optional point at which the rotation should originate as a Coordinate. Defaults to
None, representing an origin of(0, 0).
Example:
>>> obj.skewBy(11) >>> obj.skewBy((25, 10), origin=(500, 500))
Normalization¶
Environment¶
- BasePoint.naked() Any¶
Return the environment’s native object wrapped by the current object.
- Raises:
NotImplementedError – If the method has not been overridden by a subclass.
Example:
>>> loweLevelObj = obj.naked()