Remove obsolete drawing code

This commit is contained in:
numzero 2024-04-21 17:23:45 +03:00
parent 264601b8c7
commit 5d36770a2e

View File

@ -16,31 +16,6 @@ const SCALE: f32 = 30.0;
#[derive(Copy, Clone)]
struct Color(u8, u8, u8);
#[derive(Copy, Clone)]
struct Comparer {
coef: Vec2,
thr: f32,
}
impl Comparer {
fn new(a: Vec2, b: Vec2) -> Comparer {
let d = b - a;
let ortho = vec2(-d.y, d.x);
Comparer {
coef: ortho,
thr: dot(a, ortho),
}
}
fn dist(&self, p: Vec2) -> f32 {
dot(p, self.coef) - self.thr
}
fn test(&self, p: Vec2) -> bool {
self.dist(p) > 0.0
}
}
struct Image {
w: i32,
h: i32,
@ -61,21 +36,6 @@ impl Image {
self.data[index + 1] = color.1;
self.data[index + 2] = color.2;
}
fn draw_line(&mut self, a: IVec2, b: IVec2, color: Color) {}
fn draw_tri(&mut self, a: Vec2, b: Vec2, c: Vec2, color: Color) {
let u = Comparer::new(a, b);
let v = Comparer::new(b, c);
let w = Comparer::new(c, a);
for y in 0..self.h {
for x in 0..self.w {
let p = vec2(x as f32, y as f32);
if u.test(p) && v.test(p) && w.test(p) || !u.test(p) && !v.test(p) && !w.test(p) {
self.put_pixel(x, y, color);
}
}
}
}
}
fn main() -> io::Result<()> {