Function pathfinder::tools::plot
source · pub fn plot(
coordinates1: Coordinate,
coordinates2: Coordinate
) -> Vec<Coordinate>
Expand description
Implemented according to https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm
Plots the pixels between two coordinate points. Checks so that the applied adjustments stay within a u8.
Examples
First we create a simple path between two coordinates.
use pathfinder::{tools, Coordinate};
let a = Coordinate::new(0, 0);
let b = Coordinate::new(1, 1);
let path = tools::plot(a, b);
To confirm the small path created. Larger paths are more difficult to manually test.
let correct_path = vec![
Coordinate::new(0, 0),
Coordinate::new(1, 0),
Coordinate::new(1, 1),
];
assert_eq!(path, correct_path);