Expand description
This crate includes utility functions to work with svg paths. Works on types from svgtypes crate.
This package exposes functions to manipulate svg paths with simplification purposes. Also a path transformer fully compatible with svgpath is provided.
§📦 Cargo.toml
[dependencies]
svg_path_ops = "0.6"
§🔧 Example
§Translate
ⓘ
let translated_path = PathTransformer::new(cat_svg_path)
.translate(230.0, 0.0)
.to_string();
§🖨️ Output Translate
§Rotate
ⓘ
let translated_path = PathTransformer::new(cat_svg_path)
.rotate(90.0, 126.0, 140.0)
.translate(220.0, 0.0)
.to_string();
§🖨️ Output Rotate
§Skew
ⓘ
let translated_path = PathTransformer::new(cat_svg_path)
.skew_x(20.0)
.translate(180.0, 0.0)
.to_string();
§🖨️ Output Skew
§Scale
ⓘ
let translated_path = PathTransformer::new(cat_svg_path)
.scale(0.5, 0.5)
.translate(220.0, 60.0)
.to_string();
§🖨️ Output Scale
Modules§
Enums§
- Path
Segment - Representation of a path segment.
Functions§
- absolutize
- Translates relative commands to absolute commands. All commands that use relative positions (lower-case ones), turns into absolute position commands (upper-case ones).
- normalize
- Normalize takes a list of absolute segments and outputs a list of segments with only four commands: M, L, C, Z. So every segment is described as move, line, or a bezier curve (cubic). This is useful when translating SVG paths to non SVG mediums - Canvas, or some other graphics platform. Most such platforms will support lines and bezier curves. It also simplifies the cases to consider when modifying these segments.
- print_
line_ segment