Image

Overview

BaseImage.copy

Copy the current object into a new object of the same type.

BaseImage.glyph

Get or set the image's parent glyph object.

BaseImage.layer

Get the image's parent layer object.

BaseImage.font

Get the image's parent font object.

BaseImage.data

Get or set the image's raw byte data.

BaseImage.color

Get or set the image's color.

BaseImage.transformation

Get or set the image's transformation matrix.

BaseImage.offset

Get or set the image's offset.

BaseImage.scale

Get or set the image's scale.

BaseImage.transformBy

Transform the object according to the given matrix.

BaseImage.moveBy

Move the object according to the given coordinates.

BaseImage.scaleBy

Scale the object according to the given values.

BaseImage.rotateBy

Rotate the object by the specified value.

BaseImage.skewBy

Skew the object by the given value.

BaseImage.round

Round the image's offset coordinates.

BaseImage.naked

Return the environment's native object wrapped by the current object.

BaseImage.changed

Tell the environment that something has changed in the object.

Reference

class fontParts.base.BaseImage(*args: Any, **kwargs: Any)[source]

Represent the basis for an image object.

Copy

BaseImage.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 BaseObject subclass instance with the same attributes.

Parents

BaseImage.glyph

Get or set the image’s parent glyph object.

The value must be a BaseGlyph instance or None.

Returns:

The BaseGlyph instance containing the image or None.

Raises:

AssertionError – If attempting to set the glyph when it has already been set.

Example:

>>> glyph = image.glyph
BaseImage.layer: dynamicProperty

Get the image’s parent layer object.

This property is read-only.

Returns:

The BaseLayer instance containing the image or None.

Example:

>>> layer = image.layer
BaseImage.font: dynamicProperty

Get the image’s parent font object.

This property is read-only.

Returns:

The BaseFont instance containing the image or None.

Example:

>>> font = image.font

Attributes

BaseImage.data: dynamicProperty

Get or set the image’s raw byte data.

The possible formats are defined by each environment. The value must be a bytes object.

Returns:

A bytes object representing the raw byte data of the image or None.

BaseImage.color: dynamicProperty

Get or set the image’s color.

The value must be a Color or None.

Returns:

A Color instance representing the color of the image, or None.

Example:

>>> image.color
None
>>> image.color = (1, 0, 0, 0.5)
BaseImage.transformation: dynamicProperty

Get or set the image’s transformation matrix.

The value must be a Transformation Matrix.

Returns:

A Transformation Matrix value representing the transformation matrix of the image.

Example:

>>> image.transformation
(1, 0, 0, 1, 0, 0)
>>> image.transformation = (2, 0, 0, 2, 100, -50)
BaseImage.offset: dynamicProperty

Get or set the image’s offset.

The value must be a Coordinate.

Returns:

A Coordinate representing the offset of the image.

Example:

>>> image.offset
(0, 0)
>>> image.offset = (100, -50)
BaseImage.scale: dynamicProperty

Get or set the image’s scale.

The value must be a list or tuple of two int or float items representing the (x, y) scale of the image.

Returns:

A tuple of two float items representing the (x, y) scale of the image.

Example:

>>> image.scale
(1, 1)
>>> image.scale = (2, 2)

Transformations

BaseImage.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))
BaseImage.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))
BaseImage.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:
  • value – The value to scale the glyph by as a single int or float, or a tuple or list of two int or float values representing the values (x, y).

  • origin – The optional point at which the scale should originate as a Coordinate. Defaults to None, representing an origin of (0, 0).

Example:

>>> obj.scaleBy(2.0)
>>> obj.scaleBy((0.5, 2.0), origin=(500, 500))
BaseImage.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 int or a float.

  • 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))
BaseImage.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 int or float corresponding to the x direction, or a tuple of two int or float values 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

BaseImage.round() None[source]

Round the image’s offset coordinates.

Example:

>>> image.round()

Environment

BaseImage.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()
BaseImage.changed(*args: Any, **kwargs: Any) None

Tell the environment that something has changed in the object.

The behavior of this method will vary from environment to environment.

Parameters:
  • *args – Any positional arguments.

  • **kwargs – Any keyword arguments.

Example:

>>> obj.changed()