From 71069e0170d22e60125d149630416e9dab7042a5 Mon Sep 17 00:00:00 2001 From: Daniel Thompson Date: Thu, 31 Dec 2020 19:14:33 +0000 Subject: [PATCH] apps: calc: Use the UI colours to generate a background Signed-off-by: Daniel Thompson --- wasp/apps/calc.py | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/wasp/apps/calc.py b/wasp/apps/calc.py index 520ac46..1268a26 100644 --- a/wasp/apps/calc.py +++ b/wasp/apps/calc.py @@ -84,30 +84,43 @@ class CalculatorApp(): def _draw(self): draw = wasp.watch.drawable - draw.fill() + + hi = wasp.system.theme('bright') + lo = wasp.system.theme('mid') + mid = draw.lighten(lo, 2) + bg = draw.darken(wasp.system.theme('ui'), wasp.system.theme('contrast')) + bg2 = draw.darken(bg, 2) + + # Draw the background + draw.fill(0, 0, 0, 239, 47) + draw.fill(0, 236, 239, 3) + draw.fill(bg, 141, 48, 239-141, 235-48) + draw.fill(bg2, 0, 48, 140, 235-48) + # Make grid: - draw.set_color(wasp.system.theme('accent-lo')) + draw.set_color(lo) for i in range(4): # horizontal lines draw.line(x0=0,y0=(i+1)*47,x1=239,y1=(i+1)*47) # vertical lines - draw.line(x0=(i+1)*47,y0=47,x1=(i+1)*47,y1=239) - draw.line(x0=0, y0=47, x1=0, y1=239) - draw.line(x0=239, y0=47, x1=239, y1=239) - draw.line(x0=0, y0=239, x1=239, y1=239) - # Draw button label: - draw.set_color(wasp.system.theme('accent-hi')) + draw.line(x0=(i+1)*47,y0=47,x1=(i+1)*47,y1=235) + draw.line(x0=0, y0=47, x1=0, y1=236) + draw.line(x0=239, y0=47, x1=239, y1=236) + draw.line(x0=0, y0=236, x1=239, y1=236) + + # Draw button labels + draw.set_color(hi, bg2) for x in range(5): if x == 3: - draw.set_color(wasp.system.theme('accent-mid')) + draw.set_color(mid, bg) for y in range(4): label = fields[x + 5*y] if (x == 0): draw.string(label, x*47+14, y*47+60) else: draw.string(label, x*47+16, y*47+60) + draw.set_color(hi) draw.string("<", 215, 10) - draw.set_color(wasp.system.theme('accent-hi')) def _update(self): output = self.output if len(self.output) < 12 else self.output[len(self.output)-12:]