-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmockup.py
executable file
·98 lines (80 loc) · 3.17 KB
/
mockup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/python
import math
import sys
import pygame
pygame.init()
window = pygame.display.set_mode((144, 168))
dial_radius = 70
inner_radius1 = 68
inner_radius2 = 63
mid_tick_length = 5
big_tick_length = 10
num_hour_ticks = 8
num_minute_ticks = 7
hour_centre = (2, 72)
minute_centre = (142, 96)
rads = 2*math.pi
white = (255, 255, 255)
black = (0, 0, 0)
# Dials
pygame.draw.circle(window, white, hour_centre, dial_radius, 0)
pygame.draw.circle(window, white, minute_centre, dial_radius, 0)
pygame.draw.circle(window, black, hour_centre, inner_radius1, 1)
pygame.draw.circle(window, black, minute_centre, inner_radius1, 1)
# little ticks
for i in range(0, 25):
if (i % 3 != 0):
angle = rads / 48 * i
posy = -(math.cos(angle)) * inner_radius1 + hour_centre[1]
posx = math.sin(angle) * inner_radius1 + hour_centre[0]
pygame.draw.line(window, black, hour_centre, (posx, posy))
for i in range(0, 61):
if (i % 5 != 0):
angle = rads / 120 * i
posy = -(math.cos(angle)) * inner_radius1 + minute_centre[1]
posx = -(math.sin(angle)) * inner_radius1 + minute_centre[0]
pygame.draw.line(window, black, minute_centre, (posx, posy))
pygame.draw.circle(window, white, hour_centre, inner_radius2, 0)
pygame.draw.circle(window, white, minute_centre, inner_radius2, 0)
pygame.draw.circle(window, black, hour_centre, inner_radius2, 1)
pygame.draw.circle(window, black, minute_centre, inner_radius2, 1)
# big ticks on hour dial
for i in range(0, 9):
angle = rads / 16 * i
posy = -(math.cos(angle)) * inner_radius1 + hour_centre[1]
posx = math.sin(angle) * inner_radius1 + hour_centre[0]
pygame.draw.line(window, black, hour_centre, (posx, posy))
pygame.draw.circle(window, white, hour_centre, (inner_radius2-mid_tick_length), 0)
# mid ticks on minute dial
for i in range(1, 13, 2):
angle = rads / 24 * i
posy = -(math.cos(angle)) * inner_radius1 + minute_centre[1]
posx = -(math.sin(angle)) * inner_radius1 + minute_centre[0]
pygame.draw.line(window, black, minute_centre, (posx, posy))
pygame.draw.circle(window, white, minute_centre, (inner_radius2-mid_tick_length), 0)
# big ticks on minute dial
for i in range(0, 13, 2):
angle = rads / 24 * i
posy = -(math.cos(angle)) * inner_radius1 + minute_centre[1]
posx = -(math.sin(angle)) * inner_radius1 + minute_centre[0]
pygame.draw.line(window, black, minute_centre, (posx, posy))
pygame.draw.circle(window, white, minute_centre, (inner_radius2-big_tick_length), 0)
# Centres
pygame.draw.circle(window, black, hour_centre, 4, 0)
pygame.draw.circle(window, black, minute_centre, 4, 0)
# Mock up some hands
angle = rads / 48 * 13
posy = -(math.cos(angle)) * dial_radius + hour_centre[1]
posx = math.sin(angle) * dial_radius + hour_centre[0]
pygame.draw.line(window, black, hour_centre, (posx, posy))
angle = rads / 120 * 37
posy = -(math.cos(angle)) * dial_radius + minute_centre[1]
posx = -(math.sin(angle)) * dial_radius + minute_centre[0]
pygame.draw.line(window, black, minute_centre, (posx, posy))
pygame.display.flip()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit(0)
else:
print event