make the button example gay

This commit is contained in:
jacekpoz 2024-08-14 00:09:17 +02:00
parent a06c109665
commit db5d004c43
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8

View file

@ -1,30 +1,23 @@
#include <stdlib.h>
#include <ptk.h>
#include <ptk_color.h>
#include <ptk_log.h>
#include <GLFW/glfw3.h>
static const float color_step = 10.0f;
static const float step = 5.0f;
static float hue = 360.0f;
static PtkRect *r;
static void on_press(const int button, const int mods) {
(void)button; (void)mods;
PTK_DEBUG("pressed!");
r->color.b += color_step / 255.0f;
if (r->color.b > 1.0f) {
r->color.b = 0.0f;
r->color.g += color_step / 255.0f;
if (r->color.g > 1.0f) {
r->color.g = 0.0f;
r->color.r += color_step / 255.0f;
if (r->color.r > 1.0f) {
r->color.r = 0.0f;
}
}
hue += step;
if (hue > 360.0f) {
hue = 0.0f;
}
r->color = ptk_hsv_to_rgb((PtkHSV){ .h = hue, .s = 360.0f, .v = 360.0f });
}
int main(void) {
@ -35,7 +28,7 @@ int main(void) {
r = (PtkRect *)ptk_rect(
(PtkPos){ .x = 100.0f, .y = 100.0f },
(PtkSize){ .w = 100.0f, .h = 50.0f },
(PtkRGB){ .r = 1.0f, .g = 1.0f, .b = 1.0f }
(PtkRGB){ .r = 1.0f, .g = 0.0f, .b = 0.0f }
);
return ptk_run(