#polygon #2d-graphics #graphics #2d #shape

polymorpher

Library for creating and morphing potentially rounded polygons

5 releases

Uses new Rust 2024

0.1.4 Jul 5, 2025
0.1.3 Jul 4, 2025
0.1.2 Jul 3, 2025
0.1.1 Jul 3, 2025
0.1.0 Jul 3, 2025

#218 in Graphics APIs

Download history 2/week @ 2025-10-13 1/week @ 2025-10-20

150 downloads per month

Apache-2.0

110KB
2K SLoC

Polymorpher

crates.io: polymorpher Documentation Build Status License: Apache 2.0

A library for creating and morphing potentially rounded polygons. Based on the Kotlin implementation of Shape Morph from M3 Expressive.

Features

  • kurbo: implements PathBuilder for kurbo::BezPath.
  • skia: implements PathBuilder for skia_safe::PathBuilder and skia_safe::Path.
  • tiny-skia: implements PathBuilder for tiny_skia::PathBuilder.
  • lyon: implements PathBuilder for everything that implements lyon's PathBuilder.

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.

Dependencies

~0.6–1.8MB
~42K SLoC