pub struct LineGeometry {
pub start: Point,
pub end: Point,
pub half_width: f32,
pub cap: StrokeCap,
}Expand description
A stroked straight segment: its two ends, half its width and its cap,
in the units it is drawn in. crate::DrawPrimitive::Line lowers to it,
and the GPU and CPU renderers take their coverage from the same frame.
Fields§
§start: Point§end: Point§half_width: f32§cap: StrokeCapImplementations§
Source§impl LineGeometry
impl LineGeometry
Sourcepub fn new(start: Point, end: Point, stroke: Stroke) -> Self
pub fn new(start: Point, end: Point, stroke: Stroke) -> Self
The segment from start to end stroked with stroke.
Sourcepub fn is_degenerate(&self) -> bool
pub fn is_degenerate(&self) -> bool
True when the segment covers nothing: a non-finite input, no width,
or no length between butt caps, as Compose’s drawLine draws nothing
there.
Sourcepub fn frame(&self) -> LineFrame
pub fn frame(&self) -> LineFrame
The midpoint, unit direction and half length coverage is measured in. A segment of no length points along +X, so its round or square cap still draws a dot.
Sourcepub fn cap_reach(&self) -> f32
pub fn cap_reach(&self) -> f32
How far past each end the stroke reaches: half the width for round and square caps, nothing for butt caps.
Sourcepub fn end_bounds(&self) -> Rect
pub fn end_bounds(&self) -> Rect
The axis-aligned box of the ends, the rect the primitive carries.
Sourcepub fn reach(&self) -> Point
pub fn reach(&self) -> Point
How far past the ends’ box the stroke reaches on each axis: a round end’s disc bounds it by half the width every way; a butt or square end’s corners reach along the segment by the cap and across it by half the width, which on a slant is more than half the width.
Sourcepub fn bounds(&self) -> Rect
pub fn bounds(&self) -> Rect
The pixels the stroke can reach: the ends’ box grown by
Self::reach.
Sourcepub fn placed(&self, start: Point, end: Point, scale: f32) -> Self
pub fn placed(&self, start: Point, end: Point, scale: f32) -> Self
The same segment with its ends at start and end and its width
scaled by scale, as a layer’s transform places it.
Sourcepub fn coverage(&self, point: Point) -> f32
pub fn coverage(&self, point: Point) -> f32
The share of the pixel centred at point the stroke covers: exact
box coverage across the segment and along it, as a rect’s edges are
covered, so a thin line keeps its weight at any sub-pixel offset;
past the ends of a round cap, the distance to the cap’s disc.
shape.wgsl mirrors it.