make the button example gay
This commit is contained in:
parent
a06c109665
commit
db5d004c43
1 changed files with 9 additions and 16 deletions
|
@ -1,30 +1,23 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ptk.h>
|
#include <ptk.h>
|
||||||
|
#include <ptk_color.h>
|
||||||
#include <ptk_log.h>
|
#include <ptk_log.h>
|
||||||
|
|
||||||
#include <GLFW/glfw3.h>
|
static const float step = 5.0f;
|
||||||
|
static float hue = 360.0f;
|
||||||
static const float color_step = 10.0f;
|
|
||||||
|
|
||||||
static PtkRect *r;
|
static PtkRect *r;
|
||||||
|
|
||||||
static void on_press(const int button, const int mods) {
|
static void on_press(const int button, const int mods) {
|
||||||
(void)button; (void)mods;
|
(void)button; (void)mods;
|
||||||
PTK_DEBUG("pressed!");
|
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;
|
hue += step;
|
||||||
if (r->color.g > 1.0f) {
|
if (hue > 360.0f) {
|
||||||
r->color.g = 0.0f;
|
hue = 0.0f;
|
||||||
|
|
||||||
r->color.r += color_step / 255.0f;
|
|
||||||
if (r->color.r > 1.0f) {
|
|
||||||
r->color.r = 0.0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r->color = ptk_hsv_to_rgb((PtkHSV){ .h = hue, .s = 360.0f, .v = 360.0f });
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
|
@ -35,7 +28,7 @@ int main(void) {
|
||||||
r = (PtkRect *)ptk_rect(
|
r = (PtkRect *)ptk_rect(
|
||||||
(PtkPos){ .x = 100.0f, .y = 100.0f },
|
(PtkPos){ .x = 100.0f, .y = 100.0f },
|
||||||
(PtkSize){ .w = 100.0f, .h = 50.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(
|
return ptk_run(
|
||||||
|
|
Loading…
Reference in a new issue