Skip to content

Path

The Path class represents an SVG path element. It allows you to set the path data and provides computed properties based on the coordinates within the path.

Info

This class inherits from SvgElement.

pydreamplet.core.Path

Path(d: str = "", **kwargs)

Initializes a new path with an optional d attribute containing path commands.

Parameters

  • d (str, optional): The path data string.
  • **kwargs: Additional attributes for the path element.
from pydreamplet import SVG, Path
from pydreamplet.shapes import star

svg = SVG(200, 200)
svg.append(
    Path(
        d=star(svg.w / 2, svg.h / 2, inner_radius=30, outer_radius=80, angle=-18),
        fill="#a00344",
    )
)

Example

d

Getter: Returns the path data string.

Setter: Updates the path data.

print(path.d)
path.d = "M0 0 L50 50"

w

Returns the width of the path based on the extracted coordinates.

h

Returns the height of the path based on the extracted coordinates.

center

Returns the center point of the path as a Vector.