diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-07-11 15:13:55 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-07-11 15:31:15 -0700 |
commit | c76ac49f8f7ce65a778b2f1ab414fd3a8be19cb9 (patch) | |
tree | 7a8a02d116e24e69364cb72160439eff5cf6e921 /img.mu | |
parent | e8b85847967c1a1a38fc72e2eb92c917b35db1f1 (diff) | |
download | mu-c76ac49f8f7ce65a778b2f1ab414fd3a8be19cb9.tar.gz |
forget HSL conversion for now, stick to RGB
It looks like seeking the nearest neighbor in HSL space leads to more saturated colors.
Diffstat (limited to 'img.mu')
-rw-r--r-- | img.mu | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/img.mu b/img.mu index cca03989..2016f571 100644 --- a/img.mu +++ b/img.mu @@ -27,7 +27,7 @@ fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk) var img-storage: image var img/esi: (addr image) <- address img-storage load-image img, data-disk - render-image screen, img, 0/x, 0/y, 0x400/width, 0x400/height + render-image screen, img, 0/x, 0/y, 0x100/width, 0x100/height #? render-image screen, img, 0x20/x, 0x180/y, 0x12c/width=300, 0xc8/height=200 #? render-pgm-image screen, img, 0x220/x, 0x180/y, 0x12c/width=300, 0xc8/height=200 #? render-image screen, img, 0x320/x, 0x280/y, 0x60/width=96, 0x1c/height=28 @@ -833,22 +833,13 @@ fn render-ppm-image screen: (addr screen), _img: (addr image), xmin: int, ymin: copy-to b, src } idx <- increment - # color-int = nearest-hsl(r, g, b) - var color-int: int - { - var h/ecx: int <- copy 0 - var s/edx: int <- copy 0 - var l/ebx: int <- copy 0 - h, s, l <- hsl r, g, b - var tmp/eax: int <- nearest-color-euclidean-hsl h, s, l - copy-to color-int, tmp - } - # + # plot nearest color + var color/eax: int <- nearest-color-euclidean r, g, b var screenx/ecx: int <- convert x screenx <- add xmin var screeny/edx: int <- convert y screeny <- add ymin - pixel screen, screenx, screeny, color-int + pixel screen, screenx, screeny, color x <- add one-f loop } |