Drawing
momapy.drawing
Classes and objects for drawing elements (SVG-like)
Classes:
Name | Description |
---|---|
ClosePath |
Class for close-path path actions |
CompositeEffect |
Class for composite effects |
CompositionOperator |
Class for composition operators |
CurveTo |
Class for curve-to path actions |
DrawingElement |
Class for drawing elements |
DropShadowEffect |
Class for drop shadow effects |
EdgeMode |
Class for edge modes |
Ellipse |
Class for ellipse drawing elements |
EllipticalArc |
Class for elliptical-arc path actions |
FillRule |
Class for fill rules |
Filter |
Class for filters |
FilterEffect |
Class for filter effects |
FilterEffectInput |
Class for filter effect inputs |
FilterUnits |
Class for filter units |
FloodEffect |
Class for flood effects |
FontStyle |
Class for font styles |
FontWeight |
Class for font weights |
GaussianBlurEffect |
Class for Gaussian blur effects |
Group |
Class for group drawing elements |
LineTo |
Class for line-to path actions |
MoveTo |
Class for move-to path actions |
NoneValueType |
Class for none values (as in SVG) |
OffsetEffect |
Class for offset effects |
Path |
Class for the path drawing elements |
PathAction |
Abstract class for path actions |
QuadraticCurveTo |
Class for quadratic-curve-to paht actions |
Rectangle |
Class for rectangle drawing elements |
Text |
Class for text drawing elements |
TextAnchor |
Class for text anchors |
Functions:
Name | Description |
---|---|
drawing_elements_to_shapely |
Return a geometry collection reproducing the given drawing elements |
get_drawing_elements_anchor_point |
Return the anchor point of the drawing elements |
get_drawing_elements_angle |
Compute and return the point at the intersection of the given drawing elements and the line passing through the and the center of the given drawing elements and at the given angle from the horizontal |
get_drawing_elements_bbox |
Return the bounding box of the given drawing elements |
get_drawing_elements_border |
Compute and return the point at the intersection of the given drawing elements and the line passing through the given point and the center of the given drawing elements |
get_initial_value |
Return the initial value of a presentation attribute |
Attributes:
Name | Type | Description |
---|---|---|
NoneValue |
A singleton value for type |
ClosePath
dataclass
Bases: PathAction
Class for close-path path actions
Methods:
Name | Description |
---|---|
transformed |
Return a copy of the close-path path action |
transformed
transformed(transformation: Transformation, current_point: Point) -> ClosePath
Return a copy of the close-path path action
CompositeEffect
dataclass
CompositeEffect(result: str | None = None, *, in_: FilterEffectInput | str | None = None, in2: FilterEffectInput | str | None = None, operator: CompositionOperator | None = OVER)
CompositionOperator
Bases: Enum
Class for composition operators
CurveTo
dataclass
Bases: PathAction
Class for curve-to path actions
Methods:
Name | Description |
---|---|
to_geometry |
Return a bezier curve from the curve-to path action and the given current point |
to_shapely |
Return a line string reproducing the curve-to path action from the given current point |
transformed |
Compute and return a copy of the curve-to path action transformed with the given transformation and current point |
to_geometry
to_geometry(current_point: Point) -> BezierCurve
Return a bezier curve from the curve-to path action and the given current point
Source code in src/momapy/drawing.py
to_shapely
to_shapely(current_point: Point, n_segs: int = 50) -> GeometryCollection
Return a line string reproducing the curve-to path action from the given current point
Source code in src/momapy/drawing.py
transformed
transformed(transformation: Transformation, current_point: Point) -> CurveTo
Compute and return a copy of the curve-to path action transformed with the given transformation and current point
Source code in src/momapy/drawing.py
DrawingElement
dataclass
DrawingElement(*, class_: str | None = None, fill: NoneValueType | Color | None = None, fill_rule: FillRule | None = None, filter: NoneValueType | Filter | None = None, font_family: str | None = None, font_size: float | None = None, font_style: FontStyle | None = None, font_weight: FontWeight | int | None = None, id_: str | None = None, stroke: NoneValueType | Color | None = None, stroke_dasharray: tuple[float, ...] | None = None, stroke_dashoffset: float | None = None, stroke_width: float | None = None, text_anchor: TextAnchor | None = None, transform: NoneValueType | tuple[Transformation] | None = None)
Bases: ABC
Class for drawing elements
Methods:
Name | Description |
---|---|
bbox |
Compute and return the bounding box of the drawing element |
get_filter_region |
Compute and return the filter region of the drawing element |
to_shapely |
Compute and return a geometry collection built from the given drawing elements |
bbox
bbox() -> Bbox
Compute and return the bounding box of the drawing element
Source code in src/momapy/drawing.py
get_filter_region
get_filter_region() -> Bbox
Compute and return the filter region of the drawing element
Source code in src/momapy/drawing.py
to_shapely
abstractmethod
Compute and return a geometry collection built from the given drawing elements
DropShadowEffect
dataclass
DropShadowEffect(result: str | None = None, *, dx: float = 0.0, dy: float = 0.0, std_deviation: float = 0.0, flood_opacity: float = 1.0, flood_color: Color = black)
Bases: FilterEffect
Class for drop shadow effects
Methods:
Name | Description |
---|---|
to_compat |
Return a list of filter effects better supported by software that is equivalent to the given drop-shadow effect |
to_compat
to_compat() -> list[FilterEffect]
Return a list of filter effects better supported by software that is equivalent to the given drop-shadow effect
Source code in src/momapy/drawing.py
EdgeMode
Bases: Enum
Class for edge modes
Ellipse
dataclass
Ellipse(*, class_: str | None = None, fill: NoneValueType | Color | None = None, fill_rule: FillRule | None = None, filter: NoneValueType | Filter | None = None, font_family: str | None = None, font_size: float | None = None, font_style: FontStyle | None = None, font_weight: FontWeight | int | None = None, id_: str | None = None, stroke: NoneValueType | Color | None = None, stroke_dasharray: tuple[float, ...] | None = None, stroke_dashoffset: float | None = None, stroke_width: float | None = None, text_anchor: TextAnchor | None = None, transform: NoneValueType | tuple[Transformation] | None = None, point: Point, rx: float, ry: float)
Bases: DrawingElement
Class for ellipse drawing elements
Methods:
Name | Description |
---|---|
bbox |
Compute and return the bounding box of the drawing element |
get_filter_region |
Compute and return the filter region of the drawing element |
to_path |
Return a path element reproducing the ellipse element |
to_shapely |
Return a geometry collection reproducing the ellipse element |
transformed |
Compute and return a copy of the ellipse element transformed with the given transformation |
bbox
bbox() -> Bbox
Compute and return the bounding box of the drawing element
Source code in src/momapy/drawing.py
get_filter_region
get_filter_region() -> Bbox
Compute and return the filter region of the drawing element
Source code in src/momapy/drawing.py
to_path
to_path() -> Path
Return a path element reproducing the ellipse element
Source code in src/momapy/drawing.py
to_shapely
Return a geometry collection reproducing the ellipse element
Source code in src/momapy/drawing.py
transformed
transformed(transformation) -> Path
Compute and return a copy of the ellipse element transformed with the given transformation
EllipticalArc
dataclass
EllipticalArc(point: Point, rx: float, ry: float, x_axis_rotation: float, arc_flag: int, sweep_flag: int)
Bases: PathAction
Class for elliptical-arc path actions
Methods:
Name | Description |
---|---|
to_geometry |
Return an elliptical arc from the elliptical-arc path action and the given current point |
to_shapely |
Return a line string reproducing the elliptical-arc path action from the given current point |
transformed |
Compute and return a copy of the elliptical-arc path action transformed with the given transformation and current point |
to_geometry
to_geometry(current_point: Point) -> EllipticalArc
Return an elliptical arc from the elliptical-arc path action and the given current point
Source code in src/momapy/drawing.py
to_shapely
to_shapely(current_point: Point) -> GeometryCollection
Return a line string reproducing the elliptical-arc path action from the given current point
Source code in src/momapy/drawing.py
transformed
transformed(transformation: Transformation, current_point: Point) -> EllipticalArc
Compute and return a copy of the elliptical-arc path action transformed with the given transformation and current point
Source code in src/momapy/drawing.py
FillRule
Bases: Enum
Class for fill rules
Filter
dataclass
Filter(*, id: str = make_uuid4_as_str(), filter_units: FilterUnits = OBJECT_BOUNDING_BOX, effects: tuple[FilterEffect] = tuple(), width: float | str = '120%', height: float | str = '120%', x: float | str = '-10%', y: float | str = '-10%')
Bases: object
Class for filters
Methods:
Name | Description |
---|---|
to_compat |
Return a filter equivalent to the given filter with its filter effects replaced by better supported |
to_compat
Return a filter equivalent to the given filter with its filter effects replaced by better supported
Source code in src/momapy/drawing.py
FilterEffectInput
Bases: Enum
Class for filter effect inputs
FilterUnits
Bases: Enum
Class for filter units
FloodEffect
dataclass
FontStyle
Bases: Enum
Class for font styles
FontWeight
Bases: Enum
Class for font weights
GaussianBlurEffect
dataclass
GaussianBlurEffect(result: str | None = None, *, in_: FilterEffectInput | str | None = None, std_deviation: float = 0.0, edge_mode: NoneValueType | EdgeMode = NoneValue)
Group
dataclass
Group(*, class_: str | None = None, fill: NoneValueType | Color | None = None, fill_rule: FillRule | None = None, filter: NoneValueType | Filter | None = None, font_family: str | None = None, font_size: float | None = None, font_style: FontStyle | None = None, font_weight: FontWeight | int | None = None, id_: str | None = None, stroke: NoneValueType | Color | None = None, stroke_dasharray: tuple[float, ...] | None = None, stroke_dashoffset: float | None = None, stroke_width: float | None = None, text_anchor: TextAnchor | None = None, transform: NoneValueType | tuple[Transformation] | None = None, elements: tuple[DrawingElement] = tuple())
Bases: DrawingElement
Class for group drawing elements
Methods:
Name | Description |
---|---|
bbox |
Compute and return the bounding box of the drawing element |
get_filter_region |
Compute and return the filter region of the drawing element |
to_shapely |
Return a geometry collection built from the elements of the group |
transformed |
Compute and return a copy of the group transformed with the given transformation |
bbox
bbox() -> Bbox
Compute and return the bounding box of the drawing element
Source code in src/momapy/drawing.py
get_filter_region
get_filter_region() -> Bbox
Compute and return the filter region of the drawing element
Source code in src/momapy/drawing.py
to_shapely
Return a geometry collection built from the elements of the group
transformed
transformed(transformation: Transformation) -> Self
Compute and return a copy of the group transformed with the given transformation
Source code in src/momapy/drawing.py
LineTo
dataclass
LineTo(point: Point)
Bases: PathAction
Class for line-to path actions
Methods:
Name | Description |
---|---|
to_geometry |
Return a segment from the line-to path action and the given current point |
to_shapely |
Return a line string from the line-to path action and the given current point |
transformed |
Compute and return a copy of the line-to path action transformed with the given transformation and current point |
to_geometry
Return a segment from the line-to path action and the given current point
to_shapely
to_shapely(current_point: Point) -> LineString
Return a line string from the line-to path action and the given current point
transformed
transformed(transformation: Transformation, current_point: Point)
Compute and return a copy of the line-to path action transformed with the given transformation and current point
Source code in src/momapy/drawing.py
MoveTo
dataclass
MoveTo(point: Point)
Bases: PathAction
Class for move-to path actions
Methods:
Name | Description |
---|---|
transformed |
Compute and return a copy of the move-to path action transformed with the given transformation and current point |
transformed
transformed(transformation: Transformation, current_point: Point) -> MoveTo
Compute and return a copy of the move-to path action transformed with the given transformation and current point
Source code in src/momapy/drawing.py
NoneValueType
Bases: object
Class for none values (as in SVG)
OffsetEffect
dataclass
OffsetEffect(result: str | None = None, *, in_: FilterEffectInput | str | None = None, dx: float = 0.0, dy: float = 0.0)
Path
dataclass
Path(*, class_: str | None = None, fill: NoneValueType | Color | None = None, fill_rule: FillRule | None = None, filter: NoneValueType | Filter | None = None, font_family: str | None = None, font_size: float | None = None, font_style: FontStyle | None = None, font_weight: FontWeight | int | None = None, id_: str | None = None, stroke: NoneValueType | Color | None = None, stroke_dasharray: tuple[float, ...] | None = None, stroke_dashoffset: float | None = None, stroke_width: float | None = None, text_anchor: TextAnchor | None = None, transform: NoneValueType | tuple[Transformation] | None = None, actions: tuple[PathAction] = tuple())
Bases: DrawingElement
Class for the path drawing elements
Methods:
Name | Description |
---|---|
bbox |
Compute and return the bounding box of the drawing element |
get_filter_region |
Compute and return the filter region of the drawing element |
to_path_with_bezier_curves |
Compute and return a path element reproducing the path element with curves and ellipses transformed to bezier curves |
to_shapely |
Compute and return a geometry collection reproducing the path element |
transformed |
Compute and return a copy of the path element transformed with the given transformation |
bbox
bbox() -> Bbox
Compute and return the bounding box of the drawing element
Source code in src/momapy/drawing.py
get_filter_region
get_filter_region() -> Bbox
Compute and return the filter region of the drawing element
Source code in src/momapy/drawing.py
to_path_with_bezier_curves
Compute and return a path element reproducing the path element with curves and ellipses transformed to bezier curves
Source code in src/momapy/drawing.py
to_shapely
Compute and return a geometry collection reproducing the path element
Source code in src/momapy/drawing.py
transformed
transformed(transformation: Transformation) -> Self
Compute and return a copy of the path element transformed with the given transformation
Source code in src/momapy/drawing.py
QuadraticCurveTo
dataclass
Bases: PathAction
Class for quadratic-curve-to paht actions
Methods:
Name | Description |
---|---|
to_curve_to |
Return a curve-to path action repdroducing the quadratic-curve-to path action from the given current point |
to_geometry |
Return a bezier curve from the quadratic-curve-to path action and the given current point |
to_shapely |
Return a line string reproducing the quadratic-curve-to from the given current point |
transformed |
Compute and return a copy of the quadratic-curve-to transformed with the given transformation and current point |
to_curve_to
Return a curve-to path action repdroducing the quadratic-curve-to path action from the given current point
Source code in src/momapy/drawing.py
to_geometry
to_geometry(current_point: Point) -> BezierCurve
Return a bezier curve from the quadratic-curve-to path action and the given current point
Source code in src/momapy/drawing.py
to_shapely
Return a line string reproducing the quadratic-curve-to from the given current point
transformed
transformed(transformation: Transformation, current_point: Point) -> QuadraticCurveTo
Compute and return a copy of the quadratic-curve-to transformed with the given transformation and current point
Source code in src/momapy/drawing.py
Rectangle
dataclass
Rectangle(*, class_: str | None = None, fill: NoneValueType | Color | None = None, fill_rule: FillRule | None = None, filter: NoneValueType | Filter | None = None, font_family: str | None = None, font_size: float | None = None, font_style: FontStyle | None = None, font_weight: FontWeight | int | None = None, id_: str | None = None, stroke: NoneValueType | Color | None = None, stroke_dasharray: tuple[float, ...] | None = None, stroke_dashoffset: float | None = None, stroke_width: float | None = None, text_anchor: TextAnchor | None = None, transform: NoneValueType | tuple[Transformation] | None = None, point: Point, width: float, height: float, rx: float, ry: float)
Bases: DrawingElement
Class for rectangle drawing elements
Methods:
Name | Description |
---|---|
bbox |
Compute and return the bounding box of the drawing element |
get_filter_region |
Compute and return the filter region of the drawing element |
to_path |
Return a path element reproducing the rectangle element |
to_shapely |
Return a geometry collection reproducing the rectangle element |
transformed |
Compute and return a copy of the rectangle element transformed with the given transformation |
bbox
bbox() -> Bbox
Compute and return the bounding box of the drawing element
Source code in src/momapy/drawing.py
get_filter_region
get_filter_region() -> Bbox
Compute and return the filter region of the drawing element
Source code in src/momapy/drawing.py
to_path
to_path() -> Path
Return a path element reproducing the rectangle element
Source code in src/momapy/drawing.py
to_shapely
Return a geometry collection reproducing the rectangle element
transformed
transformed(transformation: Transformation) -> Path
Compute and return a copy of the rectangle element transformed with the given transformation
Text
dataclass
Text(*, class_: str | None = None, fill: NoneValueType | Color | None = None, fill_rule: FillRule | None = None, filter: NoneValueType | Filter | None = None, font_family: str | None = None, font_size: float | None = None, font_style: FontStyle | None = None, font_weight: FontWeight | int | None = None, id_: str | None = None, stroke: NoneValueType | Color | None = None, stroke_dasharray: tuple[float, ...] | None = None, stroke_dashoffset: float | None = None, stroke_width: float | None = None, text_anchor: TextAnchor | None = None, transform: NoneValueType | tuple[Transformation] | None = None, text: str, point: Point)
Bases: DrawingElement
Class for text drawing elements
Methods:
Name | Description |
---|---|
bbox |
Compute and return the bounding box of the drawing element |
get_filter_region |
Compute and return the filter region of the drawing element |
to_shapely |
Return a geometry collection built from the point of the text element |
transformed |
Return a copy of the text element |
bbox
bbox() -> Bbox
Compute and return the bounding box of the drawing element
Source code in src/momapy/drawing.py
get_filter_region
get_filter_region() -> Bbox
Compute and return the filter region of the drawing element
Source code in src/momapy/drawing.py
to_shapely
Return a geometry collection built from the point of the text element
transformed
transformed(transformation: Transformation) -> Self
TextAnchor
Bases: Enum
Class for text anchors
drawing_elements_to_shapely
drawing_elements_to_shapely(drawing_elements: Sequence[DrawingElement]) -> GeometryCollection
Return a geometry collection reproducing the given drawing elements
Source code in src/momapy/drawing.py
get_drawing_elements_anchor_point
get_drawing_elements_anchor_point(drawing_elements, anchor_point: str, center: Point | None = None) -> Point
Return the anchor point of the drawing elements
Source code in src/momapy/drawing.py
get_drawing_elements_angle
get_drawing_elements_angle(drawing_elements: Sequence[DrawingElement], angle: float, unit='degrees', center: Point | None = None) -> Point
Compute and return the point at the intersection of the given drawing elements and the line passing through the and the center of the given drawing elements and at the given angle from the horizontal
Source code in src/momapy/drawing.py
get_drawing_elements_bbox
get_drawing_elements_bbox(drawing_elements: Sequence[DrawingElement]) -> Bbox
Return the bounding box of the given drawing elements
Source code in src/momapy/drawing.py
get_drawing_elements_border
get_drawing_elements_border(drawing_elements: Sequence[DrawingElement], point: Point, center: Point | None = None) -> Point
Compute and return the point at the intersection of the given drawing elements and the line passing through the given point and the center of the given drawing elements
Source code in src/momapy/drawing.py
get_initial_value
Return the initial value of a presentation attribute