| Crates.io | tumo_path |
| lib.rs | tumo_path |
| version | 0.1.0 |
| created_at | 2026-01-22 20:30:51.916578+00 |
| updated_at | 2026-01-22 20:30:51.916578+00 |
| description | a vector path construct, manipulate, rasterizing, tessellate toolkit. |
| homepage | |
| repository | https://gitee.com/mindbox/tumo |
| max_upload_size | |
| id | 2062568 |
| size | 235,640 |
A crate for vector path operations.
This crate provides a complete toolkit for working with vector paths, including path construction, transformation, manipulation, and rendering.
The crate's design philosophy treats paths as data streams, where all operations
are implemented as type transformations on these streams. For example, converting
curves to straight lines is a transformation from Iterator<Item = PathCmd> to
Iterator<Item = LinearCmd>. This approach enables flexible composition of
operations - you can chain dash transformations, stroke operations, and linearization
in any order, with the sequence determining the processing pipeline.
std: Enables the standard library for enhanced functionalitylibm: Provides mathematical functions via the libm libraryPath construction is built around the PathCore trait, which serves as the fundamental
interface for path building operations. The trait defines six essential methods:
current: Retrieves the current endpoint of the pathmove_to: Moves to a specified point without drawingline_to: Draws a straight line to the specified pointquadratic_to: Draws a quadratic Bézier curve to the specified pointcubic_to: Draws a cubic Bézier curve to the specified pointclose: Closes the current path segmentBuilding upon PathCore, several extension traits provide enhanced functionality:
PathRelative: Enables relative path construction operationsPathExtend: Advanced curve operations including arcs and connectionsPathGeometry: Basic geometric shapes like circles, ellipses, and rectanglesPathCanvas: Web Canvas-compatible methods such as arc and arcToPathSvg: SVG-compatible path operations including arc commandsAny type implementing PathCore automatically gains these extension traits,
allowing for seamless path construction using the full feature set.
Additionally, SVG path format support is provided through the SvgCore trait,
enabling parsing of SVG path data strings.
Path manipulation is centered around iterator-based operations. The crate defines two primary path command structures:
PathCmd: Complete path commands supporting all operations including lines,
quadratic and cubic Bézier curves, and path closureLinearCmd: Simplified commands containing only straight lines and closure operationsThe crate provides iterator extensions for advanced operations:
PathCmdFlow: Extends Iterator<Item = PathCmd> with curve operations including
linearization, dashing, and rasterizationLinearCmdFlow: Extends Iterator<Item = LinearCmd> primarily for tessellation operationsConversion between command types is straightforward: Iterator<Item = PathCmd> can be
converted to Iterator<Item = LinearCmd> using the linearize method.
Paths can be converted to grayscale images through the rasterization process.
Paths are first rendered into containers implementing the Rastive trait, with
current implementations available for both Vec and Array types. The Rastive
containers provide various operations including grayscale image rendering and hit testing.
To stroke a path, first apply the stroke method on PathCmdFlow followed by
the rasterize method to generate the final image representation.
The crate implements two distinct tessellation algorithms:
This project is licensed under the MIT license. See the LICENSE file for complete licensing details.