From 208dab22566cf8c49df7548b645f860446ce08d0 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 9 May 2021 22:14:42 -0700 Subject: [PATCH] mandelbrot: add some garish color --- mandelbrot-fixed.mu | 14 ++++++-------- mandelbrot.mu | 17 ++++++----------- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/mandelbrot-fixed.mu b/mandelbrot-fixed.mu index 9cd8a793..b633cfe5 100644 --- a/mandelbrot-fixed.mu +++ b/mandelbrot-fixed.mu @@ -143,16 +143,14 @@ fn mandelbrot screen: (addr screen), scene-cx-f: int, scene-cy-f: int, scene-wid break-if->= var real-f/edx: int <- viewport-to-real-f x, width, scene-cx-f, scene-width-f var iterations/esi: int <- mandelbrot-iterations-for-point real-f, imaginary-f, 0x400/max - compare iterations, 0x400/max + iterations <- shift-right 3 + var color/edx: int <- copy 0 { - break-if->= - pixel screen, x, y, 0xf/white - } - compare iterations, 0x400/max - { - break-if-< - pixel screen, x, y, 0/black + var dummy/eax: int <- copy 0 + dummy, color <- integer-divide iterations, 0x18/24/size-of-cycle-0 + color <- add 0x20/cycle-0 } + pixel screen, x, y, color x <- increment loop } diff --git a/mandelbrot.mu b/mandelbrot.mu index ac37901b..278fafc2 100644 --- a/mandelbrot.mu +++ b/mandelbrot.mu @@ -51,22 +51,17 @@ fn mandelbrot screen: (addr screen), scene-cx: float, scene-cy: float, scene-wid compare y, height break-if->= var imaginary/xmm1: float <- viewport-to-imaginary y, width, height, scene-cy, scene-width - var x/edx: int <- copy 0 + var x/ebx: int <- copy 0 { compare x, width break-if->= var real/xmm0: float <- viewport-to-real x, width, scene-cx, scene-width var iterations/eax: int <- mandelbrot-iterations-for-point real, imaginary, 0x400/max - compare iterations, 0x400/max - { - break-if->= - pixel screen, x, y, 0xf/white - } - compare iterations, 0x400/max - { - break-if-< - pixel screen, x, y, 0/black - } + iterations <- shift-right 3 + var color/edx: int <- copy 0 + iterations, color <- integer-divide iterations, 0x18/24/size-of-cycle-0 + color <- add 0x20/cycle-0 + pixel screen, x, y, color x <- increment loop }