You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
2.1 KiB
Plaintext

(
// VISUALS
// Init vars and window
var projectionWin, scoreWin, osc_func, run = true, blend = {0} ! 27;
projectionWin = Window.new("Lamentations I: Remembering Clive Wearing", Rect(500, 500, 750, 500)).front;
projectionWin.background = Color.black;
// Keybinds (these can be change if conflicting with system keybinds)
projectionWin.view.keyDownAction = { |doc, char, mod, unicode, keycode, key|
case
// <ctrl + f> = enter full screen
{mod == 262144 && key == 70} {projectionWin.fullScreen}
// <esc> = exit full screen
{mod == 0 && key == 16777216} {projectionWin.endFullScreen}
// <ctrl + r> = run synth
{mod == 262144 && key == 82} {~flicker.run}
// <ctrl + p> = pause synth
{mod == 262144 && key == 80} {~flicker.run(false)}
// <ctrl + s> = start / fade in
{mod == 262144 && key == 83} {~fadeInTrigBus.set(1)}
// <ctrl + e> = end / fade out
{mod == 262144 && key == 69} {~fadeOutTrigBus.set(1)}
// <ctrl + t> = trigger wake
{mod == 262144 && key == 84} {~wakeTrigBus.set(1)}
};
// Get control signals from SynthDef
osc_func = OSCFunc.new({arg msg, time; blend[msg[2]] = msg[3]},'/tr', s.addr);
// Draw the window
projectionWin.drawFunc = {
var projectionRect = projectionWin.view.bounds;
{|i| var outerLen, vPad, outerSquare;
outerLen = projectionRect.width / 2;
vPad = projectionRect.height - outerLen;
outerSquare = projectionRect.insetBy(outerLen * i, vPad / 2).resizeTo(outerLen, outerLen);
outerSquare = outerSquare.insetBy(outerLen * 0.05,
outerLen * 0.05).resizeTo(outerLen * 0.9, outerLen * 0.9);
{|j| var innerLen, innerSquare;
innerLen = outerSquare.width / 3;
innerSquare = outerSquare.insetBy(innerLen * (j % 3),
innerLen * (j / 3).trunc).resizeTo(innerLen, innerLen);
Pen.addOval(innerSquare);
Pen.fillRadialGradient(innerSquare.center, innerSquare.center,
(innerSquare.width / 16), (innerSquare.width / 2),
Color.black.blend(Color.new255(255, 214, 170, 255), pow(blend[(i * 9) + j], 0.5)), Color.black);
} ! 9 } ! 2
};
projectionWin.refresh;
// Refresh function
{ while { run } { projectionWin.refresh; 30.reciprocal.wait; } }.fork(AppClock);
)