#bresenham #line #determine #point

rust_bresenham

A crate for determining Bresenham lines

1 unstable release

0.1.8 Nov 14, 2022
0.1.7 Oct 20, 2022
0.1.5 Sep 26, 2022
0.0.0 Feb 18, 2024

#380 in Graphics APIs

Download history 16/week @ 2024-05-27 1/week @ 2024-06-10 11/week @ 2024-07-29

59 downloads per month

MIT/Apache

8KB
83 lines

rust_bresenham

bresenham line

Usage with iterator

use rust_bresenham::Bresenham;

fn main() {
    let points_iter = Bresenham::new((1, 1), (3, 7));

    for point in points_iter {
        println!("{:?}", point);
        // (1, 2)
        // (2, 3)
        // (2, 4)
        // (2, 5)
        // (3, 6)
    }
}

Get all points

use rust_bresenham::Bresenham;

fn main() {
    let points: Vec<_> = Bresenham::new((3, 7), (1, 1)).collect();

    println!("points = {:?}", points);
    // points = [(3, 6), (2, 5), (2, 4), (2, 3), (1, 2)]
}

No runtime deps