Struct nannou::geom::quad::Quad[][src]

pub struct Quad<V = Vec3>(pub [V; 4]);
Expand description

A quad represented by its four vertices.

Implementations

Produce an iterator yielding each vertex in the Quad.

Produce the centroid of the quad, aka the “mean”/“average” vertex.

Triangulates the given quad, represented by four points that describe its edges in either clockwise or anti-clockwise order.

Example

The following rectangle

 a        b
  --------
  |      |
  |      |
  |      |
  --------
 d        c

given as

triangles([a, b, c, d])

returns

(Tri([a, b, c]), Tri([a, c, d]))

Here’s a basic code example:

use nannou::geom::{self, pt2, Quad, Tri};

fn main() {
    let a = pt2(0.0, 1.0);
    let b = pt2(1.0, 1.0);
    let c = pt2(1.0, 0.0);
    let d = pt2(0.0, 0.0);
    let quad = Quad([a, b, c, d]);
    let triangles = geom::quad::triangles(&quad);
    assert_eq!(triangles, (Tri([a, b, c]), Tri([a, c, d])));
}

The same as triangles but provided as an Iterator.

The bounding Rect of the quad.

The bounding Rect of the triangle.

Map the Quad’s vertices to a new type.

Methods from Deref<Target = [V; 4]>

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

Returns a slice containing the entire array. Equivalent to &s[..].

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

Borrows each element and returns an array of references with the same size as self.

Example

#![feature(array_methods)]

let floats = [3.1, 2.7, -1.0];
let float_refs: [&f64; 3] = floats.each_ref();
assert_eq!(float_refs, [&3.1, &2.7, &-1.0]);

This method is particularly useful if combined with other methods, like map. This way, you can avoid moving the original array if its elements are not Copy.

#![feature(array_methods, array_map)]

let strings = ["Ferris".to_string(), "♥".to_string(), "Rust".to_string()];
let is_ascii = strings.each_ref().map(|s| s.is_ascii());
assert_eq!(is_ascii, [true, false, true]);

// We can still access the original array: it has not been moved.
assert_eq!(strings.len(), 3);

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.

Performs the conversion.

Performs the conversion.

Performs the conversion.

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 conversion.

Performs the conversion.

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

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Convert the source color to the destination color using the specified method Read more

Convert the source color to the destination color using the bradford method by default Read more

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert into T with values clamped to the color defined bounds Read more

Convert into T. The resulting color might be invalid in its color space Read more

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more

Compare self to key and return true if they are equal.

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)

recently added

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.