2 releases

Uses old Rust 2015

0.1.1 Aug 14, 2016
0.1.0 Aug 14, 2016

#72 in Rendering engine

Download history 504/week @ 2025-03-08 390/week @ 2025-03-15 318/week @ 2025-03-22 234/week @ 2025-03-29 360/week @ 2025-04-05 267/week @ 2025-04-12 399/week @ 2025-04-19 509/week @ 2025-04-26 438/week @ 2025-05-03 367/week @ 2025-05-10 269/week @ 2025-05-17 288/week @ 2025-05-24 329/week @ 2025-05-31 336/week @ 2025-06-07 324/week @ 2025-06-14 494/week @ 2025-06-21

1,529 downloads per month
Used in 8 crates (7 directly)

MIT license

6KB
131 lines

Iterator-based Bresenham's line drawing algorithm

[Bresenham's line drawing algorithm] (https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm) is fast algorithm to draw a line between two points. This crate implements the fast integer variant, using an iterator-based appraoch for flexibility. It calculates coordinates without knowing anything about drawing methods or surfaces.

Example:

extern crate bresenham;
use bresenham::Bresenham;

fn main() {
    for (x, y) in Bresenham::new((0, 1), (6, 4)) {
        println!("{}, {}", x, y);
    }
}

Will print:

(0, 1)
(1, 1)
(2, 2)
(3, 2)
(4, 3)
(5, 3)

bresenham-rs

Implements Bresenham's line drawing algorithm in Rust using an iterator over all points in the line. Most, if not all overhead should evaporate when inlined by the compiler.

Example use:

for (x, y) in Bresenham::new((0, 1), (6, 4)) {
    println!("{}, {}", x, y);
}

Will print:

(0, 1)
(1, 1)
(2, 2)
(3, 2)
(4, 3)
(5, 3)

No runtime deps