Function conrod::widget::primitive::shape::triangles::from_quad [] [src]

pub fn from_quad(points: [Point; 4]) -> (Triangle<Point>, Triangle<Point>)

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

Example

The following rectangle

Be careful when using this code, it's not being tested!
a        b
  --------
  |      |
  |      |
  |      |
  --------
 d        c

given as

Be careful when using this code, it's not being tested!
from_quad([a, b, c, d])

returns

Be careful when using this code, it's not being tested!
(Triangle([a, b, c]), Triangle([a, c, d]))

Here's a basic code example:

extern crate conrod;

use conrod::widget::triangles::{from_quad, Triangle};

fn main() {
    let a = [0.0, 1.0];
    let b = [1.0, 1.0];
    let c = [1.0, 0.0];
    let d = [0.0, 0.0];
    let quad = [a, b, c, d];
    let triangles = from_quad(quad);
    assert_eq!(triangles, (Triangle([a, b, c]), Triangle([a, c, d])));
}