Skip to main content

LineGeometry

Struct LineGeometry 

Source
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: StrokeCap

Implementations§

Source§

impl LineGeometry

Source

pub fn new(start: Point, end: Point, stroke: Stroke) -> Self

The segment from start to end stroked with stroke.

Source

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.

Source

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.

Source

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.

Source

pub fn end_bounds(&self) -> Rect

The axis-aligned box of the ends, the rect the primitive carries.

Source

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.

Source

pub fn bounds(&self) -> Rect

The pixels the stroke can reach: the ends’ box grown by Self::reach.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for LineGeometry

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for LineGeometry

Source§

impl Debug for LineGeometry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for LineGeometry

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for LineGeometry

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.