Compare commits

...

2 commits

Author SHA1 Message Date
Able f8729fea9b Merge branch 'master' of ssh://git.ablecorp.us:20/AGL/AGL_Simple_Impl 2021-12-01 08:39:15 -06:00
Able d086432ddd triangle work 2021-12-01 08:37:14 -06:00
2 changed files with 19 additions and 3 deletions

View file

@ -32,8 +32,8 @@ impl AglApi for GraphicsRenderer {
let x2 = coords_end.x;
let y2 = coords_end.y;
let dx = x2 - x1;
let dy = y2 - y1;
let dx = x2.wrapping_sub(x1);
let dy = y2.wrapping_sub(y1);
for x in x1..x2 {
let y = y1 + dy * (x - x1) / dx;
@ -63,7 +63,9 @@ impl AglApi for GraphicsRenderer {
thickness: u32,
color: RGBA,
) {
todo!();
self.put_line(coords_1, coords_2, thickness, color);
self.put_line(coords_2, coords_3, thickness, color);
self.put_line(coords_3, coords_1, thickness, color);
}
fn paint_cursor(&mut self, coords: Point) {

View file

@ -83,6 +83,20 @@ fn main() {
},
"Hello".to_string(),
);
xyz.put_triangle(
Point { x: 10, y: 40 },
Point { x: 30, y: 100 },
Point { x: 10, y: 90 },
8,
RGBA {
r: 8,
g: 7,
b: 7,
a: 255,
},
);
// update pixels
for x in 0..600 * 400 {
buffer[x] = [xyz.buff[x].r, xyz.buff[x].g, xyz.buff[x].b, xyz.buff[x].a]