Expand description
§Polymorpher
A library for creating and morphing potentially rounded polygons. Based on the Kotlin implementation of Shape Morph from M3 Expressive.
§Features
kurbo: implementsPathBuilderforkurbo::BezPath.skia: implementsPathBuilderforskia_safe::PathBuilderandskia_safe::Path.tiny-skia: implementsPathBuilderfortiny_skia::PathBuilder.lyon: implementsPathBuilderfor everything that implementslyon’sPathBuilder.
§Example with lyon
use lyon::path::Path;
use crate::{
CornerRounding, RoundedPoint,
RoundedPolygon, geometry::Point
};
let path = RoundedPolygon::from_points(
&[
RoundedPoint::new(
Point::new(0.499, 1.023),
CornerRounding::smoothed(0.241, 0.778)
),
RoundedPoint::new(
Point::new(-0.005, 0.792),
CornerRounding::new(0.208)
),
RoundedPoint::new(
Point::new(0.073, 0.258),
CornerRounding::new(0.228)
),
RoundedPoint::new(
Point::new(0.433, -0.000),
CornerRounding::new(0.491)
),
],
1,
true,
)
.normalized()
.transformed(|point| point * 128.0)
.as_path::<Path>(false, true);
// Render it however you want!§MSRV
The Minimum Supported Rust Version is currently 1.85.1.
§License
Licensed under the Apache License, Version 2.0 to be compatible with the AOSP. This project may not be copied, modified, or distributed except according to those terms.
Modules§
- geometry
- Contains wrappers over geometric types from
euclid, an extension trait for them, and thePointTransformertrait required forRoundedPolygon::transformed. - path
- shapes
- Contains built-in functions for generating shapes.
Structs§
- Corner
Rounding - Cubic
- Contains 4 points forming a cubic Bézier curve: 2 anchor points at the start and end, and 2 control points between them.
- Double
Mapper - Feature
- While a polygon’s shape can be drawn solely using a list of
Cubicobjects representing its raw curves and lines, features add an extra layer of context to groups of cubics. - Measured
Polygon - Morph
- A structure designed to obtain transition cubics between the start and end
RoundedPolygons. - Progressable
Feature - Rounded
Point - Rounded
Polygon RoundedPolygonallows simple construction of polygonal shapes with optional rounding at the vertices.- Rounded
Polygon Builder - Provides a more convenient and familiar way to create certain shapes using
builder pattern, helping to avoid functions with hellish
Option<T>arguments.