// Copyright (jacekpoz 2024). Licensed under the EUPL-1.2 or later.
#include <stdlib.h>
#include <ptk.h>
#include <ptk_color.h>
#include <ptk_log.h>
static const float step = 5.0f;
static float hue = 360.0f;
static void on_press(PtkClickable *self, const int button, const int mods) {
(void)button; (void)mods;
PTK_DEBUG("pressed!");
hue += step;
if (hue > 360.0f) {
hue = 0.0f;
}
PtkRect *r = (PtkRect *)self->children.data[0];
r->color = ptk_hsv_to_rgb((PtkHSV){ .h = hue, .s = 360.0f, .v = 360.0f });
int main(void) {
if (!ptk_init(800, 600, "button", (PtkVersion){ .major = 0, .minor = 1, .patch = 0 })) {
return EXIT_FAILURE;
return ptk_run(
ptk_clickable(
ptk_rect(
(PtkPos){ .x = 100.0f, .y = 100.0f },
(PtkSize){ .w = 100.0f, .h = 50.0f },
(PtkRGB){ .r = 1.0f, .g = 0.0f, .b = 0.0f }
),
on_press
)
);