refeactoring more primatives into their own classes

This commit is contained in:
2026-07-07 06:47:24 -07:00
parent 19400ed32e
commit 3907c88f31
8 changed files with 289 additions and 203 deletions
+36
View File
@@ -0,0 +1,36 @@
#pragma once
#include <stdint.h>
#include "datatypes.cpp"
#include "helpers.cpp"
#include "buffer.cpp"
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
void draw (Buffer buffer, Color color) {
if (x0 > buffer.width || y0 > buffer.height || x1 > buffer.width || y1 > buffer.height) {return;};
for (uint16_t y = y0; y < y1; y++) {
for (uint16_t x = x0; x < x1; x++) {
buffer.drawPixel(Coord2(x, y), color);
}
}
return;
}
};
}