2026-07-07 06:47:24 -07:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
2026-07-07 08:09:54 -07:00
|
|
|
#include "../datatypes.cpp"
|
|
|
|
|
#include "../helpers.cpp"
|
|
|
|
|
#include "../buffer.cpp"
|
|
|
|
|
#include "../shaders/shader.cpp"
|
2026-07-07 12:17:32 -07:00
|
|
|
#include "../shaders/colorshader.cpp"
|
2026-07-07 17:57:25 -07:00
|
|
|
// #include "../shaders/gradientshader.cpp"
|
|
|
|
|
#include "../shaders/hgradientshader.cpp"
|
|
|
|
|
#include "../shaders/vgradientshader.cpp"
|
|
|
|
|
// #include "../mapper.cpp"
|
2026-07-07 06:47:24 -07:00
|
|
|
|
|
|
|
|
namespace UwU {
|
|
|
|
|
// rectangle
|
|
|
|
|
class Rectangle {
|
|
|
|
|
public:
|
|
|
|
|
Rectangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
|
|
|
|
|
this->x0 = x0;
|
|
|
|
|
this->y0 = y0;
|
|
|
|
|
this->x1 = x1;
|
|
|
|
|
this->y1 = y1;
|
|
|
|
|
}
|
|
|
|
|
Rectangle() {}
|
|
|
|
|
uint16_t x0;
|
|
|
|
|
uint16_t y0;
|
|
|
|
|
uint16_t x1;
|
|
|
|
|
uint16_t y1;
|
|
|
|
|
|
|
|
|
|
// Draw a rectangle
|
2026-07-07 17:57:25 -07:00
|
|
|
template<typename ShaderType>
|
|
|
|
|
void draw (Buffer buffer, ShaderType& shader) {
|
2026-07-07 12:17:32 -07:00
|
|
|
// printf("color: %u, %u, %u, %u", shader.color().r, shader.color().g, shader.color().b, shader.color().a);
|
2026-07-07 06:47:24 -07:00
|
|
|
if (x0 > buffer.width || y0 > buffer.height || x1 > buffer.width || y1 > buffer.height) {return;};
|
2026-07-07 17:57:25 -07:00
|
|
|
// Coord2 uv = Coord2();
|
2026-07-07 06:47:24 -07:00
|
|
|
for (uint16_t y = y0; y < y1; y++) {
|
|
|
|
|
for (uint16_t x = x0; x < x1; x++) {
|
2026-07-07 17:57:25 -07:00
|
|
|
// uv = mapper.map(Coord2(x, y));
|
|
|
|
|
Color c = shader.color(x, y);
|
|
|
|
|
buffer.drawPixel(Coord2(x, y), c);
|
2026-07-07 06:47:24 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|