// #pragma once #include "waymini/waymini.h" #include #include #include #include #include "datatypes.cpp" #include "helpers.cpp" #include "buffer.cpp" #include "surface.cpp" #include "primatives/line.cpp" #include "primatives/point.cpp" #include "primatives/rectangle.cpp" #include "primatives/trapezoid.cpp" #include "primatives/triangle.cpp" // #include "draw.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 static void onKey(void *user, uint32_t keycode, uint32_t state) { if (keycode == 1) { exit(1); } (void)user; const char *label = state ? "down" : "up "; printf("key %s: %u\n", label, keycode); fflush(stdout); } int main(void) { uint16_t w = 800, h = 480; // UwU::GradientShader fuchsia = UwU::GradientShader(UwU::Color(0xb00b69ff), UwU::Color(0xb00b6940)); // UwU::ColorShader fuchsia = UwU::ColorShader(UwU::Color(0xb00b69ff)); UwU::VGradientShader fuchsia = UwU::VGradientShader(69, UwU::Color(0xb00b69ff), 420, UwU::Color(0x00000000)); int32_t rectScale = (255 * 65536) / 351; // rectScale = 41233; //-23806 // UwU::Mapper rectMapper = UwU::Mapper(UwU::Vec2(0, 0), UwU::Vec2(0, 0), UwU::Matrix4(0, 0, 0, 0)); UwU::Color red = UwU::Color(0xff000080); UwU::Color green = UwU::Color(0x00ff00ff); UwU::Color blue = UwU::Color(0x0000ff80); // UwU::Color alpha = UwU::Color(0x00000000); UwU::Surface surface = UwU::Surface(w, h, onKey); // UwU::Buffer buffer = UwU::Buffer(surface.getWidth(), surface.getHeight()); UwU::Rectangle rectangle = UwU::Rectangle(69, 69, 420, 420); // draw.rainbow(); // draw.rectangleGradient(UwU::Coord2(200, 200), UwU::Coord2(600, 400), red, blue, alpha, red); struct timespec start, end; clock_gettime(CLOCK_MONOTONIC, &start); rectangle.draw(surface.buffer, fuchsia); clock_gettime(CLOCK_MONOTONIC, &end); long elapsed_ns = (end.tv_sec - start.tv_sec) * 1000000000L + (end.tv_nsec - start.tv_nsec); printf("Elapsed: %ld ns\n", elapsed_ns); UwU::Trapezoid trapezoid = UwU::Trapezoid(300, 400, 360, 380, 600, 480); trapezoid.draw(surface.buffer, red); UwU::Triangle triangle = UwU::Triangle(280, 100, 240, 290, 320, 300); triangle.draw(surface.buffer, blue); UwU::Point point = UwU::Point(387, 43); point.draw(surface.buffer, green); 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) }; for (uint16_t i = 0; i < 8; i++) { lines[i].draw(surface.buffer, green); } surface.present(); while (!surface.shouldClose()) {} surface.destroy(); return 0; }