-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathDurationLine.sc
65 lines (49 loc) · 1.2 KB
/
DurationLine.sc
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
DurationLine {
classvar <active = true;
var <cuePlayer, cueTrigger;
*new { arg cuePlayer;
^super.newCopyArgs(cuePlayer).getCueTriggerFromCuePlayer;
}
*on {
active = true;
}
*off {
active = false;
}
*toggle {
if(active,
{ active = false },
{ active = true });
}
getCueTriggerFromCuePlayer {
Server.default.waitForBoot{
cueTrigger = cuePlayer.guiInstance.cueTrigger;
}
}
create {
arg duration = 5, color = Color.white, width = 2;
if(active and:{cueTrigger.lrgCueWin.notNil}, {
this.animation(duration, color, width);
});
}
animation {
arg duration = 5, color = Color.white, width = 2;
var offset = 0;
var penFunction;
AppClock.sched(duration+2, {
cueTrigger.removeFromDrawFunc(penFunction);
});
penFunction = {
Pen.use {
Pen.width = width;
Pen.color_(color);
Pen.beginPath;
Pen.moveTo(Point(0+offset,0));
Pen.lineTo(Point(0+offset, cueTrigger.lrgWinBounds.height));
Pen.stroke;
offset = offset + (cueTrigger.lrgWinBounds.width+20 / (duration*cueTrigger.frameRate));
};
};
cueTrigger.addToDrawFunc(penFunction);
}
}