summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/julia_set.c18
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;