-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclock_style
90 lines (77 loc) · 1.66 KB
/
clock_style
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
/*
simple 2d clock-style beat display
the beat is assigned to the bottom of the circle, the clock hand swings past
this point on the ictus of each beat. A visual indication of beat membership
is triggered within a threshold of +/- 0.1 of beat phase. The display is driven
via a float phase input. Whole numbers correspond to beats and intermediate
float values indicate some fraction of the beat around the circle.
One notes the low-priority queue limitations here--particularly for faster beat
values, the "blink" on the beat becomes intermittent due to the low frame refresh
rate of the GUI object.
Jeremy Wagner, July 26, 2022
*/
sketch.default2d();
var val = 0;
var theta=0;
var r = 0.8;
var blink = false;
draw();
function draw()
{
var width = box.rect[2] - box.rect[0];
with (sketch) {
shapeslice(180,1);
// erase background
glclearcolor(0,0,0,1);
glclear();
moveto(0,0);
gllinewidth(1);
glcolor(1,1,1,1);
circle(0.8);
glcolor(0,0,0,1);
circle(0.78);
glcolor(1,1,1,1);
lineto(0.8*Math.cos(theta),0.8*Math.sin(theta));
moveto(0,0);
lineto(0,-0.8);
if(blink){
blink=false;
circle(0.2);
glcolor(0,0,0,1);
circle(.15);
}
glcolor(1,1,1,1);
circle(0.05);
}
}
function bang()
{
draw();
refresh();
outlet(0,val);
}
function msg_float(v)
{
theta = -(v+.25 % 1.0) * 6.2831853072;
if(Math.abs(v % 1.0)<0.1){
blink = true;
}
notifyclients();
bang();
}
function forcesize(w,h)
{
if (w!=h) {
h = w;
box.size(w,h);
}
}
forcesize.local = 1; //private
function onresize(w,h)
{
forcesize(w,h);
r = 0.4*Math.min(box.rect[2] - box.rect[0], box.rect[3] - box.rect[1]);
draw();
refresh();
}
onresize.local = 1; //private