neoscore.core.image

class neoscore.core.image.Image[source]

Bases: PositionedObject

An image which can be placed in the document.

Supported image extensions/formats include: BMP, GIF, JPG, JPEG, PNG, PBM, PGM, PPM, XBM, XPM, and SVG.

__init__(pos: PointDef, parent: Optional[PositionedObject], file_path: str | pathlib.Path, scale: float = 1, rotation: float = 0, transform_origin: PointDef = ORIGIN)[source]
Parameters
  • pos – Position relative to the parent

  • parent – The parent object or None

  • file_path – Path to an image file to be used

  • scale – A scaling factor applied to the image.

  • rotation – Rotation angle in degrees.

property file_path: pathlib.Path

Path to an image file to be used

property breakable_length: Unit

The breakable length of the object.

This is always ZERO, meaning images cannot be broken across Flowable lines.

render_complete(pos: Point, flowable_line: Optional[NewLine] = None, flowable_x: Optional[Unit] = None)[source]

Render the entire object.

This is used to render all objects outside flowables, as well as those inside flowables when they fit completely in one line of the flowable.

By default, this is a no-op. Subclasses with rendered appearances should override this.

This method behaves differently inside and outside of flowables. Whether this object is inside a flowable can be determined by whether a flowable_line is given. When inside a flowable, the given position is in global document coordinates, and created interfaces (or higher level classes) must not be assigned a parent. When not inside a flowable, the given position is relative to self.parent and created interfaces (or higher level classes) must be assigned a parent. In this case, created interfaces should use self.parent.interface_for_children as their parent.

This and other render methods should generally not be called directly.

Parameters
  • pos – The rendering position. If outside a flowable, this is relative to the parent. Otherwise, it is in document coordinates.

  • flowable_line – If in a Flowable, the line in which this object appears

  • flowable_x – If in a Flowable, the flowable x position of this render