svg_path/transform/serialize
SVG transform attribute serializer.
This module serializes affine matrices as SVG transform attribute strings.
It prefers readable transform functions such as translate, scale,
rotate, and skew when a matrix clearly matches them, and falls back to
matrix(a b c d e f) otherwise.
Types
Options for SVG transform serialization.
pub type Options {
Options(
decimal_places: option.Option(Int),
fixed_decimals: Bool,
force_matrix: Bool,
)
}
Constructors
-
Options( decimal_places: option.Option(Int), fixed_decimals: Bool, force_matrix: Bool, )
Values
pub fn decimal_options(decimal_places: Int) -> Options
Create options that round numbers to the given number of decimal places.
Trailing zeroes are stripped. Negative decimal places are clamped to zero.
pub fn default_options() -> Options
Default transform serialization options.
Defaults to up to 5 decimal places, stripped trailing zeroes, and readable transform functions when possible.
pub fn fixed_decimal_options(decimal_places: Int) -> Options
Create options that round numbers and keep exactly the given number of decimal places.
Negative decimal places are clamped to zero.
pub fn force_matrix(options: Options) -> Options
Force serialization as matrix(a b c d e f).
This disables the nicer translate, scale, rotate, and skew
representations.
pub fn to_string(transform: transform.Matrix) -> String
Serialize a transform matrix with default options.
pub fn to_string_with_options(
transform transform: transform.Matrix,
options options: Options,
) -> String
Serialize a transform matrix with custom options.