From 04d06dfe537703885ae30230940e5756fecdcb19 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Mon, 21 Sep 2020 23:42:57 -0700 Subject: 6831 - tile: preserve color contrast Formula from Chris Maughan: (0.2126*R + 0.7152*G + 0.0722*B) > 0.5 --- apps/tile/environment.mu | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'apps') 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 -- cgit 1.4.1-2-gfad0