about summary refs log tree commit diff stats
path: root/apps/tile/environment.mu
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-09-21 23:42:57 -0700
committerKartik Agaram <vc@akkartik.com>2020-09-21 23:42:57 -0700
commit04d06dfe537703885ae30230940e5756fecdcb19 (patch)
treef9496f20f7d2eff4811c3ef57d6f117183ec9972 /apps/tile/environment.mu
parenta4f5e386951ff175e0fda97b9e2079a2bc6e171c (diff)
downloadmu-04d06dfe537703885ae30230940e5756fecdcb19.tar.gz
6831 - tile: preserve color contrast
Formula from Chris Maughan: (0.2126*R + 0.7152*G + 0.0722*B) > 0.5
Diffstat (limited to 'apps/tile/environment.mu')
-rw-r--r--apps/tile/environment.mu18
1 files changed, 17 insertions, 1 deletions
diff --git a/apps/tile/environment.mu b/apps/tile/environment.mu
index cbedece3..14a8490b 100644
--- a/apps/tile/environment.mu
+++ b/apps/tile/environment.mu
@@ -261,7 +261,23 @@ fn render-column screen: (addr screen), first-word: (addr word), final-word: (ad
 # synaesthesia
 fn render-integer screen: (addr screen), val: int {
   var bg/eax: int <- hash-color val
-  start-color screen, 7, bg
+  var fg/ecx: int <- copy 7
+  {
+    compare bg, 2
+    break-if-!=
+    fg <- copy 0
+  }
+  {
+    compare bg, 3
+    break-if-!=
+    fg <- copy 0
+  }
+  {
+    compare bg, 6
+    break-if-!=
+    fg <- copy 0
+  }
+  start-color screen, fg, bg
   print-grapheme screen, 0x20  # space
   print-int32-decimal screen, val
   print-grapheme screen, 0x20  # space