From 50d6c374de23adebc7a3a2742c6c20dfd87010fb Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 17 Oct 2024 09:39:34 -0700 Subject: fix other mandelbrot variants --- apps/mandelbrot-fixed.mu | 5 ++--- apps/mandelbrot-silhouette.mu | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'apps') diff --git a/apps/mandelbrot-fixed.mu b/apps/mandelbrot-fixed.mu index fc33aae1..186350aa 100644 --- a/apps/mandelbrot-fixed.mu +++ b/apps/mandelbrot-fixed.mu @@ -213,8 +213,8 @@ fn mandelbrot-y x-f: int, y-f: int, imaginary-f: int -> _/ebx: int { } # Scale (x, y) pixel coordinates to a complex plane where the viewport width -# ranges from -2 to +2. Viewport height just follows the viewport's aspect -# ratio. +# ranges from (scene-cx - scene-width/2) to (scene-cx + scene-width/2). +# Viewport height just follows the viewport's aspect ratio. fn viewport-to-real-f x: int, width: int, scene-cx-f: int, scene-width-f: int -> _/edx: int { # 0 in the viewport goes to scene-cx - scene-width/2 @@ -239,7 +239,6 @@ fn viewport-to-imaginary-f y: int, width: int, height: int, scene-cy-f: int, sce # height in the viewport goes to scene-cy + scene-width/2*height/width # Therefore: # y in the viewport goes to (scene-cy - scene-width/2*height/width) + y*scene-width/width - # scene-cy - scene-width/width * (height/2 + y) # At most two numbers being multiplied before a divide, so no risk of overflow. var result-f/eax: int <- int-to-fixed y result-f <- multiply-fixed result-f, scene-width-f diff --git a/apps/mandelbrot-silhouette.mu b/apps/mandelbrot-silhouette.mu index 0d9a137c..14c6e397 100644 --- a/apps/mandelbrot-silhouette.mu +++ b/apps/mandelbrot-silhouette.mu @@ -113,8 +113,8 @@ fn mandelbrot-y x: float, y: float, imaginary: float -> _/xmm3: float { } # Scale (x, y) pixel coordinates to a complex plane where the viewport width -# ranges from -2 to +2. Viewport height just follows the viewport's aspect -# ratio. +# ranges from (scene-cx - scene-width/2) to (scene-cx + scene-width/2). +# Viewport height just follows the viewport's aspect ratio. fn viewport-to-real x: int, width: int -> _/xmm0: float { # (x - width/2)*4/width -- cgit 1.4.1-2-gfad0