diff options
author | Mitya Selivanov <automainint@guattari.tech> | 2025-01-14 04:13:45 +0100 |
---|---|---|
committer | Mitya Selivanov <automainint@guattari.tech> | 2025-01-14 04:13:45 +0100 |
commit | c9208089c6074575342d529f494295c13269a1aa (patch) | |
tree | e87af3b94f573ab48989a265561dc6016d69812b /examples | |
parent | a3cf8790cb4547288c9d395609738c4a1eb838a2 (diff) | |
download | reduced_system_layer-c9208089c6074575342d529f494295c13269a1aa.zip |
Rectangle anti-aliasing
Diffstat (limited to 'examples')
-rw-r--r-- | examples/pixels.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/examples/pixels.c b/examples/pixels.c new file mode 100644 index 0000000..c47ac35 --- /dev/null +++ b/examples/pixels.c @@ -0,0 +1,44 @@ +#define MIN_PIXEL_SIZE 16 +#include "../graphics.c" + +i64 t = 0; +f64 x = 100.; +f64 y = 100.; + +void update_and_render_frame(void) { + p_handle_events(); + + i64 time_elapsed = p_time() - t; + t += time_elapsed; + + if (g_platform.key_down[KEY_LEFT]) x -= .01 * time_elapsed; + if (g_platform.key_down[KEY_RIGHT]) x += .01 * time_elapsed; + if (g_platform.key_down[KEY_UP]) y -= .01 * time_elapsed; + if (g_platform.key_down[KEY_DOWN]) y += .01 * time_elapsed; + + Brush white = RGB(1.f, 1.f, 1.f); + Brush black = RGB(0.f, 0.f, 0.f); + + black.antialiasing = 1; + + fill_rectangle(white, 0., 0., g_platform.real_width, g_platform.real_height); + fill_rectangle(black, x, y, 40., 40.); + + p_render_frame(); + p_sleep_for(0); +} + +i32 main(i32 argc, c8 **argv) { + (void) argc; + (void) argv; + + g_platform = (Platform) { + .title = "Pixels", + }; + + t = p_time(); + + p_event_loop(); + + return 0; +} |