added gradient shader logic to trapezoids
This commit is contained in:
+10
-10
@@ -32,9 +32,9 @@ static void onKey(void *user, uint32_t keycode, uint32_t state) {
|
||||
|
||||
int main(void) {
|
||||
uint16_t w = 800, h = 480;
|
||||
UwU::Shader fuchsia = UwU::Shader(UwU::Direction::H, 69, 420, UwU::Color(0xb00b69ff), UwU::Color(0x00000000));
|
||||
UwU::Shader fuchsia = UwU::Shader(UwU::Direction::H, 360, 600, UwU::Color(0xb00b69ff), UwU::Color(0x00000000));
|
||||
UwU::Shader red = UwU::Shader(UwU::Direction::V, 69, 420, UwU::Color(0xff0000ff), UwU::Color(0x00000000));
|
||||
UwU::Shader warmup = UwU::Shader(UwU::Color(0xb00b69ff));
|
||||
UwU::Color red = UwU::Color(0xff000080);
|
||||
UwU::Color green = UwU::Color(0x00ff00ff);
|
||||
UwU::Color blue = UwU::Color(0x0000ff80);
|
||||
// UwU::Color alpha = UwU::Color(0x00000000);
|
||||
@@ -43,7 +43,11 @@ int main(void) {
|
||||
// UwU::Buffer buffer = UwU::Buffer(surface.getWidth(), surface.getHeight());
|
||||
|
||||
UwU::Rectangle rectangle = UwU::Rectangle(69, 69, 420, 420);
|
||||
UwU::Trapezoid trapezoid = UwU::Trapezoid(300, 400, 360, 380, 600, 480);
|
||||
UwU::Triangle triangle = UwU::Triangle(280, 100, 240, 290, 320, 300);
|
||||
UwU::Point point = UwU::Point(387, 43);
|
||||
|
||||
rectangle.draw(surface.buffer, red);
|
||||
|
||||
// Benchmarking
|
||||
struct timespec start, end;
|
||||
@@ -52,13 +56,13 @@ int main(void) {
|
||||
const int SAMPLES = 10;
|
||||
|
||||
for (int i = 0; i < WARMUP; i++) {
|
||||
rectangle.draw(surface.buffer, fuchsia);
|
||||
trapezoid.draw(surface.buffer, fuchsia);
|
||||
}
|
||||
long times[SAMPLES];
|
||||
for (int s = 0; s < SAMPLES; s++) {
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
for (int i = 0; i < BATCH; i++) {
|
||||
rectangle.draw(surface.buffer, fuchsia);
|
||||
trapezoid.draw(surface.buffer, fuchsia);
|
||||
}
|
||||
clock_gettime(CLOCK_MONOTONIC, &end);
|
||||
times[s] = (end.tv_sec - start.tv_sec) * 1000000000L + (end.tv_nsec - start.tv_nsec);
|
||||
@@ -71,14 +75,10 @@ int main(void) {
|
||||
timeAvg /= BATCH;
|
||||
printf("Elapsed: %ld ns\n", timeAvg);
|
||||
|
||||
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),
|
||||
|
||||
Reference in New Issue
Block a user