tropical32 / rust_bresenham

Bresenham's line implementation in Rust

Home Page:https://crates.io/crates/rust_bresenham

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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)]
}

About

Bresenham's line implementation in Rust

https://crates.io/crates/rust_bresenham


Languages

Language:Rust 100.0%