rewrote example.cpp to use composition
This commit is contained in:
+46
-25
@@ -8,12 +8,15 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "datatypes.cpp"
|
||||
#include "draw.cpp"
|
||||
#include "trapezoid.cpp"
|
||||
#include "helpers.cpp"
|
||||
#include "triangle.cpp"
|
||||
#include "buffer.cpp"
|
||||
#include "surface.cpp"
|
||||
#include "trapezoid.cpp"
|
||||
#include "line.cpp"
|
||||
#include "rectangle.cpp"
|
||||
#include "point.cpp"
|
||||
#include "draw.cpp"
|
||||
|
||||
static void onKey(void *user, uint32_t keycode, uint32_t state) {
|
||||
if (keycode == 1) {
|
||||
@@ -26,43 +29,61 @@ static void onKey(void *user, uint32_t keycode, uint32_t state) {
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
uint32_t w = 800, h = 480;
|
||||
UwU::Color fuchsia = UwU::Color(0xb00b6940);
|
||||
UwU::Color red = UwU::Color(0xff0000ff);
|
||||
uint16_t w = 800, h = 480;
|
||||
UwU::Color fuchsia = UwU::Color(0xb00b6980);
|
||||
UwU::Color red = UwU::Color(0xff000080);
|
||||
UwU::Color green = UwU::Color(0x00ff00ff);
|
||||
UwU::Color blue = UwU::Color(0x0000ffff);
|
||||
UwU::Color blue = UwU::Color(0x0000ff80);
|
||||
UwU::Color alpha = UwU::Color(0x00000000);
|
||||
printf("r: %u, g:%u, b:%u, a:%u\n", fuchsia.r, fuchsia.g, fuchsia.b, fuchsia.a);
|
||||
|
||||
// struct waymini *wm = waymini_create(w, h, on_key, NULL);
|
||||
UwU::Draw draw = UwU::Draw(w, h, onKey);
|
||||
// UwU::Draw draw = UwU::Draw(w, h, onKey);
|
||||
UwU::Surface surface = UwU::Surface(w, h, onKey);
|
||||
|
||||
draw.rainbow();
|
||||
// draw.rainbow();
|
||||
|
||||
|
||||
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.rectangle(UwU::Coord2(69, 69), UwU::Coord2(420, 420), fuchsia);
|
||||
UwU::Rectangle rectangle = UwU::Rectangle(69, 69, 420, 420);
|
||||
rectangle.draw(surface.buffer, fuchsia);
|
||||
|
||||
draw.trapezoid(UwU::Trapezoid(300, 400, 360, 380, 600, 480), green);
|
||||
draw.triangle(280, 100, 240, 290, 320, 300, green);
|
||||
// draw.rectangleGradient(UwU::Coord2(200, 200), UwU::Coord2(600, 400), red, blue, alpha, red);
|
||||
|
||||
// draw.trapezoid(UwU::Trapezoid(300, 400, 360, 380, 600, 480), red);
|
||||
UwU::Trapezoid trapezoid = UwU::Trapezoid(300, 400, 360, 380, 600, 480);
|
||||
trapezoid.draw(surface.buffer, red);
|
||||
|
||||
// draw.triangle(280, 100, 240, 290, 320, 300, blue);
|
||||
UwU::Triangle triangle = UwU::Triangle(280, 100, 240, 290, 320, 300);
|
||||
triangle.draw(surface.buffer, blue);
|
||||
|
||||
// myTrap = UwU:Trapezoid(300, 400, 360, 380, 600, 480);
|
||||
// myTrap.draw()
|
||||
|
||||
|
||||
draw.point(UwU::Coord2(387, 43), green);
|
||||
draw.line(UwU::Line(300, 100, 250, 469), green);
|
||||
draw.line(UwU::Line(250, 100, 300, 469), green);
|
||||
draw.line(UwU::Line(300, 100, 469, 250), green);
|
||||
draw.line(UwU::Line(469, 100, 300, 250), green);
|
||||
draw.line(UwU::Line(100, 300, 250, 469), green);
|
||||
draw.line(UwU::Line(250, 300, 100, 469), green);
|
||||
draw.line(UwU::Line(100, 300, 469, 250), green);
|
||||
draw.line(UwU::Line(469, 300, 100, 250), green);
|
||||
draw.present();
|
||||
// draw.point(UwU::Point(387, 43), green);
|
||||
UwU::Point point = UwU::Point(387, 43);
|
||||
point.draw(surface.buffer, green);
|
||||
|
||||
while (!draw.shouldClose()) {}
|
||||
UwU::Line lines[8] {
|
||||
UwU::Line(300, 100, 250, 469),
|
||||
UwU::Line(250, 100, 300, 469),
|
||||
UwU::Line(300, 100, 469, 250),
|
||||
UwU::Line(469, 100, 300, 250),
|
||||
UwU::Line(100, 300, 250, 469),
|
||||
UwU::Line(250, 300, 100, 469),
|
||||
UwU::Line(100, 300, 469, 250),
|
||||
UwU::Line(469, 300, 100, 250)
|
||||
};
|
||||
|
||||
draw.destroy();
|
||||
for (uint16_t i = 0; i < 8; i++) {
|
||||
lines[i].draw(surface.buffer, green);
|
||||
}
|
||||
|
||||
surface.present();
|
||||
|
||||
while (!surface.shouldClose()) {}
|
||||
|
||||
surface.destroy();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user