Files
UwUGL/datatypes.cpp
T
2026-07-05 20:55:17 -07:00

69 lines
1.4 KiB
C++

#pragma once
#include <stdint.h>
namespace UwU {
// Color datatype returns individual channel values from rgba hexcode
struct Color {
Color(uint32_t hex) {
this->a = hex & 0x000000ff;
this->b = (hex & 0x0000ff00) >> 8;
this->g = (hex & 0x00ff0000) >> 16;
this->r = (hex & 0xff000000) >> 24;
}
Color() {}
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t a;
};
// Coord2 datatype for xy coordinates, from top-left of surface
struct Coord2 {
Coord2(uint32_t x, uint32_t y) {
this->x = x;
this->y = y;
}
Coord2() {}
uint32_t x;
uint32_t y;
};
// trapezoid datatype (horizontally constrained)
struct Trapezoid {
Trapezoid(uint16_t y0, uint16_t y1, uint16_t xl0, uint16_t xl1, uint16_t xr0, uint16_t xr1) {
this->y0 = y0;
this->y1 = y1;
this->xl0 = xl0;
this->xl1 = xl1;
this->xr0 = xr0;
this->xr1 = xr1;
}
Trapezoid() {}
uint16_t y0;
uint16_t y1;
uint16_t xl0;
uint16_t xl1;
uint16_t xr0;
uint16_t xr1;
};
struct Triangle {
Triangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) {
this->x0 = x0;
this->y0 = y0;
this->x1 = x1;
this->y1 = y1;
this->x2 = x2;
this->y2 = y2;
}
Triangle() {}
uint16_t x0;
uint16_t y0;
uint16_t x1;
uint16_t y1;
uint16_t x2;
uint16_t y2;
};
}