diff --git a/test b/test index fd10411..119b616 100755 Binary files a/test and b/test differ diff --git a/test.cpp b/test.cpp index 5a78fa8..768d8f7 100644 --- a/test.cpp +++ b/test.cpp @@ -263,7 +263,7 @@ namespace UwU { Coord2 mid = Coord2(); Coord2 btm = Coord2(); // cases: flat top, flat bottom, left point, right point - if (coords.y0 < coords.y1 && coords.y0 < coords.y2) { + if (coords.y0 <= coords.y1 && coords.y0 <= coords.y2) { top.x = coords.x0; top.y = coords.y0; if (coords.y1 < coords.y2) { @@ -277,7 +277,7 @@ namespace UwU { btm.x = coords.x1; btm.y = coords.y1; } - } else if (coords.y1 < coords.y0 && coords.y1 < coords.y2) { + } else if (coords.y1 <= coords.y0 && coords.y1 <= coords.y2) { top.x = coords.x1; top.y = coords.y1; if (coords.y0 < coords.y2) { @@ -306,17 +306,24 @@ namespace UwU { btm.y = coords.y0; } } + printf("top: (%u, %u)\n", top.x, top.y); + printf("mid: (%u, %u)\n", mid.x, mid.y); + printf("btm: (%u, %u)\n", btm.x, btm.y); uint16_t height = 1 + btm.y - top.y; int16_t longBound[height]; int16_t splitBound[height]; // int16_t rightBound[height]; Helpers::bresenham(0, top.x, height - 1, btm.x, longBound); + printf("longBound\n"); if ((int16_t)mid.x < longBound[mid.y - top.y]) { // left-handed triangle + printf("left-handed\n"); // rightBound = longBound; Helpers::bresenham(0, top.x, mid.y - top.y, mid.x, splitBound); + printf("splitTop\n"); Helpers::bresenham(mid.y - top.y, mid.x, height - 1, btm.x, splitBound); + printf("splitBtm\n"); for (uint32_t i = 0; i < height; i++) { 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); @@ -324,9 +331,12 @@ namespace UwU { } } else { // right-handed triangle + printf("right-handed\n"); // leftBound = longBound; Helpers::bresenham(0, top.x, mid.y - top.y, mid.x, splitBound); + printf("splitTop\n"); Helpers::bresenham(mid.y - top.y, mid.x, height - 1, btm.x, splitBound); + printf("splitBtm\n"); for (uint32_t i = 0; i < height; i++) { for (uint32_t x = (uint32_t)longBound[i]; x <= (uint32_t)splitBound[i]; x++) { putPixel(x, i + (uint32_t)top.y, color.r, color.g, color.b, color.a); @@ -399,9 +409,9 @@ int main(void) { draw.rectangle(UwU::Coord2(69, 69), UwU::Coord2(420, 420), fuchsia); - 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);