Aller au contenu principal

raygeo.svg

Functions

parse_svg_path_data()

parse_svg_path_data(path_data: str, transform: numpy.NDArray[numpy.float64] | None = None, scale_x: float = 1, scale_y: float = 1) -> list[Geometry]

Parse an SVG path d attribute into a list of Geometry objects.

Supports M/m, L/l, H/h, V/v, C/c, Z/z commands. Cubic Bezier curves are flattened to line segments (20 steps).

Returns: List of Geometry objects, one per subpath.

ParameterTypeDescription
path_datastrSVG path d attribute string.
transform`numpy.NDArray[numpy.float64]None = None`
scale_xfloat = 1X-axis scale factor for coordinate transform.
scale_yfloat = 1Y-axis scale factor for coordinate transform.
Returnslist[Geometry]

parse_svg_transform()

parse_svg_transform(transform_str: str) -> numpy.NDArray[numpy.float64]

Parse an SVG transform attribute string (translate only).

Returns a 3x3 identity matrix with translation applied.

Returns: 3x3 affine transformation matrix as numpy array.

ParameterTypeDescription
transform_strstrSVG transform attribute value.
Returnsnumpy.NDArray[numpy.float64]

svg_string_to_geometries()

svg_string_to_geometries(svg_str: str, scale_x: float = 1, scale_y: float = 1) -> list[Geometry]

Parse an SVG string and extract all path elements as Geometry objects.

Recursively traverses the SVG XML tree, extracting d attributes from path elements and converting them to Geometry.

Returns: List of Geometry objects from all path elements.

ParameterTypeDescription
svg_strstrSVG document as a string.
scale_xfloat = 1X-axis scale factor for coordinate transform.
scale_yfloat = 1Y-axis scale factor for coordinate transform.
Returnslist[Geometry]