pub fn fill_polygon(points: &[Vec2], fill: impl Into<Fill>)Expand description
Filled, anti-aliased convex polygon through points in either winding.
Every edge gets the same half-pixel fringe as the rounded shapes, so icons,
arrows, stars (as triangles) and badges built from polygons sit smoothly
beside circles and rounded rectangles. Very sharp corners are mitred to at
most four times the fringe width. Concave or self-intersecting input is not
rejected but fills as the fan from its centroid; split such outlines into
convex pieces. Fewer than three distinct corners, more than
MAX_POLYGON_POINTS, zero area or non-finite input draw nothing.
Emits at most 576 vertices.
use ferravex_render::{Color, vec2, shapes};
// A play triangle and a hexagon badge.
shapes::fill_polygon(&[vec2(20., 10.), vec2(44., 24.), vec2(20., 38.)],
Color::from_hex(0xf7b553));
let hex: Vec<_> = (0..6).map(|i| {
let a = i as f32 * std::f32::consts::TAU / 6.;
vec2(100. + 20. * a.cos(), 24. + 20. * a.sin())
}).collect();
shapes::fill_polygon(&hex, Color::from_hex(0x5bd5d8));