A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.rs/embedded-graphics/latest/embedded_graphics/primitives/line/struct.Line.html below:

Line in embedded_graphics::primitives::line - Rust

pub struct Line {
    pub start: Point,
    pub end: Point,
}
Expand description

Line primitive

§Examples §Create some lines with different styles
use embedded_graphics::{
    pixelcolor::Rgb565, prelude::*, primitives::{Line, PrimitiveStyle},
};

Line::new(Point::new(50, 20), Point::new(60, 35))
    .into_styled(PrimitiveStyle::with_stroke(Rgb565::RED, 1))
    .draw(&mut display)?;

Line::new(Point::new(50, 20), Point::new(60, 35))
    .translate(Point::new(-30, 10))
    .into_styled(PrimitiveStyle::with_stroke(Rgb565::GREEN, 10))
    .draw(&mut display)?;

Start point

End point

Source§ Source

Creates a line between two points.

Source

Creates a line with a start point and a delta vector.

§Examples
use embedded_graphics::{prelude::*, primitives::Line};

let line = Line::with_delta(Point::new(10, 20), Point::new(20, -20));
Source

Compute the midpoint of the line.

Source

Compute the delta (end - start) of the line.

Source§ Source§ Source§ Source§ Source§ Source§

Writes the defmt representation of self to fmt.

Source§ Source§ Source§ Source§

Tests for self and other values to be equal, and is used by ==.

1.0.0 · Source§

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Source§ Source§

This method returns an ordering between

self

and

other

values if one exists.

Read more 1.0.0 · Source§

Tests less than (for

self

and

other

) and is used by the

<

operator.

Read more 1.0.0 · Source§

Tests less than or equal to (for

self

and

other

) and is used by the

<=

operator.

Read more 1.0.0 · Source§

Tests greater than (for

self

and

other

) and is used by the

>

operator.

Read more 1.0.0 · Source§

Tests greater than or equal to (for

self

and

other

) and is used by the

>=

operator.

Read more Source§ Source§

Iterator over all points inside the primitive.

Source§

Returns an iterator over all points inside the primitive.

Source§ Source§

Converts this primitive into a Styled.

Source§ Source§

Returns the bounding box using the given style.

Source§ Source§ Source§

Translate the line from its current position to a new position by (x, y) pixels, returning a new Line. For a mutating transform, see translate_mut.

let line = Line::new(Point::new(5, 10), Point::new(15, 20));
let moved = line.translate(Point::new(10, 10));

assert_eq!(moved.start, Point::new(15, 20));
assert_eq!(moved.end, Point::new(25, 30));
Source§

Translate the line from its current position to a new position by (x, y) pixels.

let mut line = Line::new(Point::new(5, 10), Point::new(15, 20));
line.translate_mut(Point::new(10, 10));

assert_eq!(line.start, Point::new(15, 20));
assert_eq!(line.end, Point::new(25, 30));
Source§ Source§ Source§

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4