[−][src]Function nannou::geom::line::quad_corners
pub fn quad_corners<S>(a: Point2<S>, b: Point2<S>, half_thickness: S) -> Quad<S> where
S: BaseFloat,
Given two points and half the line thickness, return the four corners of the rectangle describing the line.
Given a line a -> b, the indices are laid out as follows:
ⓘThis example is not tested
1 2 ---------------------------------------- |a b| ---------------------------------------- 0 3
Examples
use nannou::prelude::*; use nannou::geom::line; fn main() { let half_thickness = 1.0; let a = pt2(0.0, 0.0); let b = pt2(2.0, 0.0); // ab let expected = [pt2(0.0, -1.0), pt2(0.0, 1.0), pt2(2.0, 1.0), pt2(2.0, -1.0)]; assert_eq!(expected, line::quad_corners(a, b, half_thickness).0); // ba let expected = [pt2(2.0, 1.0), pt2(2.0, -1.0), pt2(0.0, -1.0), pt2(0.0, 1.0)]; assert_eq!(expected, line::quad_corners(b, a, half_thickness).0); }