fixed issue with bresenham high detection

This commit is contained in:
2026-07-06 12:23:06 -07:00
parent 1d27f6e5d1
commit 95e9e92b40
7 changed files with 6 additions and 3 deletions
+2 -2
View File
@@ -79,7 +79,7 @@ namespace UwU {
} }
return; return;
} }
if (abs(y1 - y0) <= x1) { if (abs(y1 - y0) <= abs(x1 - x0)) {
bresenhamLow(x0, y0, x1, y1, LUT); bresenhamLow(x0, y0, x1, y1, LUT);
} else { } else {
if (y0 > y1) { if (y0 > y1) {
@@ -91,4 +91,4 @@ namespace UwU {
return; return;
} }
}; };
} }
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+4 -1
View File
@@ -324,6 +324,9 @@ namespace UwU {
printf("splitTop\n"); printf("splitTop\n");
Helpers::bresenham(mid.y - top.y, mid.x, height - 1, btm.x, splitBound); Helpers::bresenham(mid.y - top.y, mid.x, height - 1, btm.x, splitBound);
printf("splitBtm\n"); printf("splitBtm\n");
for (uint16_t i = 0; i < height; i++) {
printf("(%u, %u)\n", i, splitBound[i]);
}
for (uint32_t i = 0; i < height; i++) { for (uint32_t i = 0; i < height; i++) {
for (uint32_t x = (uint32_t)splitBound[i]; x <= (uint32_t)longBound[i]; x++) { for (uint32_t x = (uint32_t)splitBound[i]; x <= (uint32_t)longBound[i]; x++) {
putPixel(x, i + (uint32_t)top.y, color.r, color.g, color.b, color.a); putPixel(x, i + (uint32_t)top.y, color.r, color.g, color.b, color.a);
@@ -412,7 +415,7 @@ int main(void) {
// draw.rectangleGradient(UwU::Coord2(200, 200), UwU::Coord2(600, 400), red, blue, alpha, red); // draw.rectangleGradient(UwU::Coord2(200, 200), UwU::Coord2(600, 400), red, blue, alpha, red);
// draw.trapezoid(UwU::Trapezoid(300, 400, 360, 380, 600, 400), green); // draw.trapezoid(UwU::Trapezoid(300, 400, 360, 380, 600, 400), green);
draw.triangle(UwU::Triangle(280, 100, 240, 100, 320, 300), green); draw.triangle(UwU::Triangle(280, 100, 240, 290, 320, 300), green);
draw.point(UwU::Coord2(387, 43), green); draw.point(UwU::Coord2(387, 43), green);
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.