Skip to content

ellipse_path

The path of the ellipse that fills a box, as SVG path data: two half-turn arcs. A square box gives a circle.

use helpers4::geometry::ellipse_path;

Cargo feature geometry (enabled by default). To compile only this module:

cargo add helpers4 --no-default-features --features geometry

or in Cargo.toml:

[dependencies]
helpers4 = { version = "0.0.11", default-features = false, features = ["geometry"] }
pub fn ellipse_path(bounds: Rect) -> String
ParameterTypeDescription
boundsRectThe bounding box of the ellipse.

String — The path data, closed.

use helpers4::geometry::{ellipse_path, Rect};

assert_eq!(
    ellipse_path(Rect::new(0.0, 0.0, 10.0, 6.0)),
    "M0 3 A5 3 0 0 1 10 3 A5 3 0 0 1 0 3 Z"
);

src/geometry/ellipse_path.rs