bit of code cleanup

This commit is contained in:
2026-07-08 14:05:42 -07:00
parent 04afd9eee0
commit b7032c3b8e
8 changed files with 31 additions and 163 deletions
+2 -19
View File
@@ -5,12 +5,7 @@
#include "../datatypes.cpp"
#include "../helpers.cpp"
#include "../buffer.cpp"
#include "../shaders/shader.cpp"
// #include "../shaders/colorshader.cpp"
// #include "../shaders/gradientshader.cpp"
// #include "../shaders/hgradientshader.cpp"
// #include "../shaders/vgradientshader.cpp"
// #include "../mapper.cpp"
#include "../shader.cpp"
namespace UwU {
// rectangle
@@ -32,22 +27,10 @@ namespace UwU {
void draw (Buffer buffer, Shader shader) {
if (shader.shaderType == COLOR) {
if (x0 > buffer.width || y0 > buffer.height || x1 > buffer.width || y1 > buffer.height) {return;};
Color c = shader.c0;
uint8_t r = c.r;
uint8_t g = c.g;
uint8_t b = c.b;
size_t stride = buffer.stride;
size_t i = (size_t)y0 * buffer.stride + (size_t)x0 * 4;
for (uint16_t y = y0; y < y1; y++) {
for (uint16_t x = x0; x < x1; x++) {
// buffer.drawPixel(Coord2(x, y), shader.c0);
buffer.pixels[i + 0] = b;
buffer.pixels[i + 1] = g;
buffer.pixels[i + 2] = r;
buffer.pixels[i + 3] = 255;
i += 4;
buffer.drawPixel(Coord2(x, y), shader.c0);
}
i += stride - ((x1 - x0) * 4);
}
return;