diff options
author | Mitya Selivanov <automainint@guattari.tech> | 2025-01-17 01:43:36 +0100 |
---|---|---|
committer | Mitya Selivanov <automainint@guattari.tech> | 2025-01-17 01:43:36 +0100 |
commit | f5ed02329aed6d455257e0932a194161d88efdd6 (patch) | |
tree | eda08fac35bbf0ceba4138d92d10efd01ab4d954 /examples/julia_set.c | |
parent | e8972a0c2f344e109a9763a396f3ef54a646dfaa (diff) | |
download | reduced_system_layer-f5ed02329aed6d455257e0932a194161d88efdd6.zip |
Web framerate calibration; Julia Set example update
Diffstat (limited to 'examples/julia_set.c')
-rw-r--r-- | examples/julia_set.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/examples/julia_set.c b/examples/julia_set.c index e5a2734..6ae8e6f 100644 --- a/examples/julia_set.c +++ b/examples/julia_set.c @@ -43,15 +43,23 @@ void update_and_render_frame(void) { view_y += g_platform.cursor_dy * view_s; } - view_s += .1 * g_platform.wheel_dy * view_s; + if (g_platform.wheel_dy != 0.) { + f64 dx = (g_platform.cursor_x * 1. - g_platform.real_width * .5); + f64 dy = (g_platform.cursor_y * 1. - g_platform.real_height * .5); + view_x -= view_s * dx; + view_y -= view_s * dy; + view_s += view_s * g_platform.wheel_dy * .1; + view_x += view_s * dx; + view_y += view_s * dy; + } for (i32 j = 0; j < g_platform.frame_height; ++j) for (i32 i = 0; i < g_platform.frame_width; ++i) { - f64 kx = ((f64) g_platform.real_width) / g_platform.frame_width * view_s; - f64 ky = ((f64) g_platform.real_height) / g_platform.frame_height * view_s; + f64 kx = ((f64) g_platform.real_width) / g_platform.frame_width; + f64 ky = ((f64) g_platform.real_height) / g_platform.frame_height; - f64 x = .003 * ((i - g_platform.frame_width * .5) * kx - view_x); - f64 y = .003 * ((j - g_platform.frame_height * .5) * ky - view_y); + f64 x = .003 * ((i - (g_platform.frame_width - 1) * .5) * kx * view_s - view_x); + f64 y = .003 * ((j - (g_platform.frame_height - 1) * .5) * ky * view_s - view_y); i64 n = 0; |