Struct pix_engine::shape::Line[][src]

#[repr(transparent)]
pub struct Line<T, const N: usize>(_);
Expand description

A Line with start and end Points.

Please see the module-level documentation for examples.

Implementations

Constructs a Line from start to end Points.

Example
// 2D
let line = Line::new([10, 20], [30, 10]);

let p1 = point![10, 20];
let p2 = point![30, 10];
let line = Line::new(p1, p2);

// 3D
let line: Line<i32, 3> = Line::new([10, 20, 5], [30, 10, 5]);

Constructs a Line from individual x/y coordinates.

Constructs a Line from individual x/y/z coordinates.

Returns the starting point of the line.

Sets the starting point of the line.

Returns the ending point of the line.

Sets the ending point of the line.

Returns Line coordinates as [x1, y1, z1, x2, y2, z2].

Example
let p1 = point!(5, 10);
let p2 = point!(100, 100);
let l = Line::new(p1, p2);
assert_eq!(l.as_array(), [point!(5, 10), point!(100, 100)]);

Returns Line coordinates as a byte slice &[x1, y1, z1, x2, y2, z2].

Example
let p1 = point!(5, 10);
let p2 = point!(100, 100);
let l = Line::new(p1, p2);
assert_eq!(l.as_bytes(), &[point!(5, 10), point!(100, 100)]);

Returns Line coordinates as a mutable byte slice &mut [x1, y1, z1, x2, y2, z2].

Example
let p1 = point!(5, 10);
let p2 = point!(100, 100);
let mut l = Line::new(p1, p2);
for p in l.as_bytes_mut() {
    *p += 5;
}
assert_eq!(l.as_bytes(), &[point!(10, 15), point!(105, 105)]);

Returns Line as a Vec.

Example
let p1 = point!(5, 10);
let p2 = point!(100, 100);
let l = Line::new(p1, p2);
assert_eq!(l.to_vec(), vec![[5, 10], [100, 100]]);

Returns Self with the numbers cast using as operator. Converts Line < T, N > to Line < U, N >.

Returns Line < T, N > with the nearest integers to the numbers. Round half-way cases away from 0.0.

Returns Line < T, N >with the largest integers less than or equal to the numbers.

Returns Line < T, N > with the smallest integers greater than or equal to the numbers.

Trait Implementations

Performs the conversion.

Performs the conversion.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Deserialize this value from the given Serde deserializer. Read more

Converts &[T; M] to Line < T, N >.

Converts Line < T, N > to &[T; M].

Converts [T; M] to Line < T, N >.

Converts Line < T, N > to [T; M].

Creates a value from an iterator. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

Performs the mutable indexing (container[index]) operation. Read more

Returns the closest intersection point with a given line and distance along the line or None if there is no intersection.

Returns whether this line intersections with another line

The shape type. e.g. Rect<T>.

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.