-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclock.py
74 lines (59 loc) · 2.18 KB
/
clock.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
##########################################################
##########################################################
# description: example that works with connection/disconnections of boxes
#
# autor: jeraman
# date: 26/04/2010
##########################################################
##########################################################
#imports Pyata library
from pyata.pd import *
import math
#planet class for rotate boxes
class Clock():
def __init__(self, radius, center, processes, lifetime, inlet=0):
self.radius = radius
self.center = center
self.inlet = inlet
self.list = []
self.pointer = 0
self.processes = processes
self.draw()
self.lifetime = lifetime
def increment(self):
self.lifetime=self.lifetime-1
disconnect(self.list[self.pointer][0], 0, self.center[0], self.inlet)
self.pointer = (self.pointer+1)%len(self.processes)
i = self.pointer
exp = (float(self.processes[i][1])*100/pow(2,float(self.processes[i][1])/10))+110
connect(self.list[self.pointer][0], 0, self.center[0], self.inlet)
self.list[self.pointer][0].set(exp)
def destroy(self):
self.list.reverse()
for b in self.list:
b[0].delete()
b[1].delete()
sleep(0.1)
for c in self.center:
c.delete()
sleep(0.1)
def draw(self):
q_boxes = len(self.processes)
total = 360
slice_angle = total/q_boxes
angle = -90 - slice_angle
for i in range(0,q_boxes):
angle += slice_angle
rad_angle = math.radians(angle)
x = self.radius * math.cos(rad_angle)
y = self.radius * math.sin(rad_angle)
x+=self.center[0].x
y+=self.center[0].y
x = int(x)
y = int(y)
#print self.processes[i]
n = Number(x, y)
c = Comment(x, y-20, self.processes[i][0])
#exp = (float(self.processes[i][1])*100/pow(2,float(self.processes[i][1])/10))+110
#n.set(exp)
self.list.append([n,c])