Skip to content

G

The G class represents a group (<g>) element in SVG. It inherits from both SvgElement and Transformable to allow grouped elements to be transformed together.

Info

This class inherits from Transformable and SvgElement.

pydreamplet.core.G

G(
    pos: Vector = None,
    scale: Vector = None,
    angle: float = 0,
    pivot: Vector = None,
    order: str = "trs",
    **kwargs
)

Initializes a group element with optional transformation properties and a pivot point.

Parameters

  • pos (Vector, optional): Position vector (default: (0, 0)).
  • scale (Vector, optional): Scale vector (default: (1, 1)).
  • angle (float): Rotation angle (default: 0).
  • pivot (Vector, optional): Pivot point for rotation (default: (0, 0)).
  • order (str): Transformation order (combination of 't', 'r', 's'; default: "trs").
group = G(pos=Vector(10, 20), angle=30)

pivot

Getter: Returns the pivot point as a Vector.

Setter: Updates the pivot point and refreshes the transform.

print(group.pivot)
group.pivot = Vector(5, 5)

order

Getter: Returns the current transformation order.

Setter: Updates the order and refreshes the transform.

print(group.order)
group.order = "rts"

remove

remove(self, child) -> G

Removes a child element. If the group becomes empty, it removes itself from its parent.

attrs

attrs(self, attributes: dict) -> G

Sets multiple attributes on the group, including parsing transformation details.

from_element

G.from_element(element: ET.Element)

Creates a G instance from an ElementTree element by parsing its transformation attributes.