Donner
C++20 SVG rendering library
Loading...
Searching...
No Matches
donner::svg::parser::TransformParser Class Reference

Parse an SVG transform attribute, such as translate(100 100), using the SVG syntax which does not support units on numbers. More...

#include "donner/svg/parser/TransformParser.h"

Static Public Member Functions

static ParseResult< TransformdParse (std::string_view str)
 Parse an SVG transform attribute.
 

Detailed Description

Parse an SVG transform attribute, such as translate(100 100), using the SVG syntax which does not support units on numbers.

See also
https://www.w3.org/TR/css-transforms-1/#svg-transform

Member Function Documentation

◆ Parse()

ParseResult< Transformd > donner::svg::parser::TransformParser::Parse ( std::string_view str)
static

Parse an SVG transform attribute.

See also
https://www.w3.org/TR/css-transforms-1/#svg-transform

Compared to the CSS transform attribute, this parser does not support units on numbers, and the default units are pixels and degrees.

  • translate(100 100) - translates by (100, 100) pixels.
  • rotate(45) - rotates by 45 degrees.

Supported functions:

Function Description
matrix(a, b, c, d, e, f) Matrix transform.
See also
donner::Transform
translate(x, y=0) Translates by (x, y) pixels.
scale(x, y=x) Scales by (x, y).
rotate(angle) Rotates by angle degrees.
rotate(angle, cx, cy) Rotates by angle degrees around (cx, cy).
skewX(angle) Skews by angle degrees along the X axis.
skewY(angle) Skews by angle degrees along the Y axis.

Commas between parameters are optional, and multiple transform functions may be composed for more complex transforms, such as rotate(45) translate(100 100).

Parameters
strString corresponding to the SVG transform attribute.
Returns
Parsed transform, or an error.

The documentation for this class was generated from the following files: