Skip to main content

segment_coverage

Function segment_coverage 

Source
pub fn segment_coverage(
    p: PointPx,
    a: PointPx,
    b: PointPx,
    half_width: Px,
) -> f32
Expand description

Coverage of the pixel centered at p by the segment a→b drawn 2 × half_width wide with round caps (consecutive segments of a polyline join without gaps). Anti-aliased over one pixel. Shader: segment_coverage().

§Examples

use ferrochart_core::geom::{PointPx, Px};
use ferrochart_core::transform_helpers::segment_coverage;

let (a, b) = (PointPx { x: 0.0, y: 10.0 }, PointPx { x: 20.0, y: 10.0 });
assert_eq!(segment_coverage(PointPx { x: 5.5, y: 10.5 }, a, b, Px(1.0)), 1.0);
assert_eq!(segment_coverage(PointPx { x: 5.5, y: 13.5 }, a, b, Px(1.0)), 0.0);