Bitmap/Bresenham's line algorithm: Difference between revisions
Content added Content deleted
Line 3,325: | Line 3,325: | ||
fn draw_line(line: std::vec::Vec<Point>, width: i32, height: i32) { |
fn draw_line(line: std::vec::Vec<Point>, width: i32, height: i32) { |
||
for col in 0..height { |
for col in 0..height { |
||
let mut col_as_string: String = "".to_string(); |
|||
for row in 0..width { |
for row in 0..width { |
||
let is_point_in_line = line.iter().any(| point| point.x == row && point.y == col); |
let is_point_in_line = line.iter().any(| point| point.x == row && point.y == col); |
||
match is_point_in_line { |
match is_point_in_line { |
||
true => |
true => print!("❖"), |
||
_ => { |
_ => { |
||
if col == 0 || col == (height - 1) || row == 0 || row == (width - 1) { |
if col == 0 || col == (height - 1) || row == 0 || row == (width - 1) { |
||
print!("☗"); |
|||
} else { |
} else { |
||
print!("."); |
|||
} |
} |
||
} |
} |
||
}; |
}; |
||
} |
} |
||
print!("\n"); |
|||
} |
} |
||
} |
} |