summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2020-05-18 21:19:19 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2020-05-18 21:19:19 (GMT)
commit60bb43e87b86bddd0792d1e7d6be373640a109f0 (patch)
tree92973f3d7f28fdd70d9c82f183c824dae77739c7
parent7f6b1b9059a3537726e0cda706a1898bd8e9ac8e (diff)
apps: gameoflife: Better pixel colour selection
-rw-r--r--wasp/apps/gameoflife.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/wasp/apps/gameoflife.py b/wasp/apps/gameoflife.py
index 80c5528..f1f1dbe 100644
--- a/wasp/apps/gameoflife.py
+++ b/wasp/apps/gameoflife.py
@@ -36,11 +36,11 @@ def xorshift12(v: int) -> int:
@micropython.viper
def get_color(v: int) -> int:
- r = v >> 10
- g = (v >> 8) & 7
- b = (v >> 5) & 3
-
- return (r << 13) | (g << 7) | (b << 1) | 0x9c73
+ """Convert a 12-bit number into a reasonably bright RGB565 pixel"""
+ rgb = v ^ (v << 4)
+ while 0 == (rgb & 0xc710):
+ rgb += 0x2104
+ return rgb
@micropython.viper
def get_cell(board, stride: int, x: int, y: int) -> bool: