lucem_hist::polygon
Outlines: area, perimeter, centroid, point inside, and labels traced into outlines.
Functions
Section titled “Functions”pub fn area(p: &[Point]) -> f64perimeter
Section titled “perimeter”pub fn perimeter(p: &[Point]) -> f64centroid
Section titled “centroid”pub fn centroid(p: &[Point]) -> PointThe centroid of the enclosed area (the mean of the points for a degenerate outline).
contains
Section titled “contains”pub fn contains(p: &[Point], q: Point) -> boolWhether q is inside p (even-odd rule).
bounds
Section titled “bounds”pub fn bounds(p: &[Point]) -> (f64, f64, f64, f64)The bounding box (x0, y0, x1, y1).
trace_labels
Section titled “trace_labels”pub fn trace_labels( labels: &[u32], w: usize, h: usize, origin: Point, ds: f64,) -> Vec<(u32, Polygon)>The outer outline of every label of a w × h raster (pixel corners, level-0 pixels:
origin + corner · ds), by label. Each pixel side between a label and anything else is an
edge; edges chain into loops and the largest loop of a label is its outline (holes are left
out). Points along straight runs are dropped.
pub fn fill( p: &[Point], raster: &mut [u32], w: usize, h: usize, origin: Point, ds: f64, value: u32,)Fills p (level-0 pixels) into a w × h raster of a region at origin with ds level-0
pixels per raster pixel: pixels whose centre is inside get value.