Skip to content

Transformable

The Transformable mixin adds transformation capabilities—translation, rotation, and scaling—to SVG elements. It is intended for use with group elements.

pydreamplet.core.Transformable

Transformable(
    pos: Vector = None,
    scale: Vector = None,
    angle: float = 0,
    *args,
    **kwargs
)

Initializes transformation properties with position, scale, and rotation angle.

Parameters

  • pos (Vector, optional): Position vector (default: (0, 0)).
  • scale (Vector, optional): Scale vector (default: (1, 1)).
  • angle (float): Rotation angle (default: 0).
t = Transformable(pos=Vector(10, 20), scale=Vector(2, 2), angle=45)

pos

Getter: Returns the current position as a Vector.

Setter: Updates the position and refreshes the transform.

print(t.pos)
t.pos = Vector(30, 40)

scale

Getter: Returns the current scale as a Vector.

Setter: Updates the scale and refreshes the transform.

print(t.scale)
t.scale = Vector(1, 1)

angle

Getter: Returns the current rotation angle.

Setter: Updates the angle and refreshes the transform.

print(t.angle)
t.angle = 90