A library for creating and morphing potentially rounded polygons. Based on the Kotlin implementation of Shape Morph from M3 Expressive.
kurbo
: implementsPathBuilder
forkurbo::BezPath
.skia
: implementsPathBuilder
forskia_safe::PathBuilder
andskia_safe::Path
.tiny-skia
: implementsPathBuilder
fortiny_skia::PathBuilder
.lyon
: implementsPathBuilder
for everything that implementslyon
'sPathBuilder
.
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!
The Minimum Supported Rust Version is currently 1.85.1.
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.