|
17 | 17 | CY = HEIGHT // 2 |
18 | 18 |
|
19 | 19 | # Couple of colours for use later |
20 | | -WHITE = display.create_pen(255, 255, 255) |
21 | | -RED = display.create_pen(230, 60, 45) |
22 | | -GREEN = display.create_pen(9, 185, 120) |
23 | 20 | BLACK = display.create_pen(0, 0, 0) |
| 21 | +hue = 0.09 |
| 22 | +background = display.create_pen_hsv(hue, 0.8, 1.0) |
| 23 | +foreground = display.create_pen_hsv(hue, 0.5, 1.0) |
| 24 | +text_colour = display.create_pen_hsv(hue, 0.2, 1.0) |
24 | 25 |
|
25 | 26 | # We'll need this for the touch element of the screen |
26 | 27 | touch = presto.touch |
|
36 | 37 | vector.set_transform(t) |
37 | 38 |
|
38 | 39 | # Touch buttons |
39 | | -start_button = Button(1, HEIGHT - 50, CX - 2, 49) |
40 | | -stop_button = Button(WIDTH - CX, HEIGHT - 50, CX - 2, 49) |
| 40 | +start_button = Button(3, HEIGHT - 55, CX - 5, 49) |
| 41 | +stop_button = Button((WIDTH - CX) + 1, HEIGHT - 55, CX - 5, 49) |
41 | 42 |
|
42 | 43 | start = Polygon() |
43 | | -start.rectangle(*start_button.bounds, (5, 5, 5, 5)) |
| 44 | +start.rectangle(*start_button.bounds, (10, 10, 10, 10)) |
44 | 45 |
|
45 | 46 | stop = Polygon() |
46 | | -stop.rectangle(*stop_button.bounds, (5, 5, 5, 5)) |
| 47 | +stop.rectangle(*stop_button.bounds, (10, 10, 10, 10)) |
47 | 48 |
|
48 | 49 | outline = Polygon() |
49 | | -outline.rectangle(5, 20, WIDTH - 10, HEIGHT - 100, (5, 5, 5, 5), 2) |
| 50 | +outline.rectangle(5, 20, WIDTH - 10, HEIGHT - 100, (10, 10, 10, 10), 2) |
| 51 | + |
| 52 | +# We'll use a rect with rounded corners for the background. |
| 53 | +background_rect = Polygon() |
| 54 | +background_rect.rectangle(0, 0, WIDTH, HEIGHT, (10, 10, 10, 10)) |
50 | 55 |
|
51 | 56 |
|
52 | 57 | class StopWatch(object): |
@@ -87,28 +92,31 @@ def return_string(self): |
87 | 92 |
|
88 | 93 | while True: |
89 | 94 |
|
90 | | - display.set_pen(WHITE) |
| 95 | + display.set_pen(BLACK) |
91 | 96 | display.clear() |
92 | 97 |
|
93 | | - display.set_pen(GREEN) |
| 98 | + display.set_pen(background) |
| 99 | + vector.draw(background_rect) |
| 100 | + |
| 101 | + display.set_pen(foreground) |
94 | 102 | vector.draw(start) |
95 | 103 |
|
96 | | - display.set_pen(RED) |
| 104 | + display.set_pen(foreground) |
97 | 105 | vector.draw(stop) |
98 | 106 |
|
99 | | - display.set_pen(BLACK) |
| 107 | + display.set_pen(text_colour) |
100 | 108 | vector.draw(outline) |
101 | 109 |
|
102 | 110 | vector.set_font_size(32) |
103 | 111 | if timer.elapsed and timer.running is False: |
104 | | - vector.text("Resume", start_button.bounds[0] + 10, start_button.bounds[1] + 33) |
| 112 | + vector.text("Resume", start_button.bounds[0] + 8, start_button.bounds[1] + 33) |
105 | 113 | else: |
106 | 114 | vector.text("Start", start_button.bounds[0] + 27, start_button.bounds[1] + 33) |
107 | 115 |
|
108 | 116 | if timer.running: |
109 | 117 | vector.text("Stop", stop_button.bounds[0] + 30, stop_button.bounds[1] + 33) |
110 | 118 | else: |
111 | | - vector.text("Reset", stop_button.bounds[0] + 25, stop_button.bounds[1] + 33) |
| 119 | + vector.text("Reset", stop_button.bounds[0] + 23, stop_button.bounds[1] + 33) |
112 | 120 |
|
113 | 121 | if start_button.is_pressed() and timer.running is False: |
114 | 122 | timer.start() |
|
0 commit comments