Skip to content

tropical32/rust_line_rasterizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LineRasterizer

line rasterization

Usage

Get all points

use rust_line_rasterizer::LineRasterizer;

fn main(){
    let points: Vec<_> = LineRasterizer::new((0, 0), (2, 4)).collect();
    println!("points = {:?}", points);
    // points = [(0, 1), (1, 1), (1, 2), (1, 3), (2, 3)]
}

Iterate points

use rust_line_rasterizer::LineRasterizer;

fn main() {
    let line_rasterizer_iter = LineRasterizer::new((2, 4), (0, 0));

    for point in line_rasterizer_iter {
        println!("{:?}", point);
        // (2, 3)
        // (1, 3)
        // (1, 2)
        // (1, 1)
        // (0, 1)
    }
}

Releases

No releases published

Packages

No packages published

Languages