[][src]Static gridly::vector::TOUCHING_ADJACENCIES

pub static TOUCHING_ADJACENCIES: [Vector; 8]

This array contains unit vectors associated with the 8 adjacent directions. It is intended to allow for easy iteration over all locations that touch a center location (for instance, when scanning adjacencies in an implementation of Conway's Game of Life). The order of the vectors is unspecified and should not be relied upon.

Example

use gridly::prelude::*;
use gridly::shorthand::*;
let root = L(1, 2);
let touching: Vec<Location> = TOUCHING_ADJACENCIES.iter().map(|v| root + v).collect();

assert!(touching.contains(&L(0, 1)));
assert!(touching.contains(&L(0, 3)));
assert!(touching.contains(&L(2, 3)));
assert!(touching.contains(&L(2, 1)));
assert!(touching.contains(&L(0, 2)));
assert!(touching.contains(&L(2, 2)));
assert!(touching.contains(&L(1, 3)));
assert!(touching.contains(&L(1, 1)));
assert_eq!(touching.len(), 8);

Death to the false Emperor