This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Hackpact2015 laad.com.mx/hackpact2015eng.html | |
#Day 2 | |
s.reboot | |
( | |
( | |
~makeWin = { | |
arg partial = 1, bounds = Rect(0,0,400,400); | |
var win = Window.new(partial.asString, bounds).front; | |
var proxy = Ndef(partial.asSymbol, { | |
arg amp=0.1, detune=0; | |
LFCub.ar(80 * (partial + 1 + ([0, detune].scramble/10))).unipolar * amp * 0.2; | |
}).play; | |
win.drawFunc = { |v| | |
var centre = (v.bounds.width/2)@(v.bounds.height/2); | |
var mouse = (Platform.getMouseCoords.x - win.bounds.left)@(Platform.getMouseCoords.y - (win.bounds.top - 356)); | |
var detune = (((mouse.x - centre.x).atan2(mouse.y - centre.y))/pi); | |
var amp = (v.bounds.width*v.bounds.height)/(Window.screenBounds.width*Window.screenBounds.height); | |
Pen.strokeColor = Color.red; | |
Pen.line(centre, mouse); | |
Pen.stroke; | |
proxy.set(\amp, amp, \detune, detune); | |
}; | |
win.onClose = { proxy.end(0.1); }; | |
win; | |
}; | |
) | |
( | |
var hori = true; | |
var left = true; | |
var top = true; | |
var area = Window.availableBounds; | |
var w = area.width; | |
var h = area.height; | |
var l = area.left; | |
var t = area.top; | |
var partial = 0; | |
var wins = []; | |
while( | |
{(w > 20) and: (h > 20)}, | |
{ | |
var bt = t; | |
var bl = l; | |
if(hori, { | |
if(top, { | |
t = t + (h/2); | |
}, { | |
bt = t + (h/2); | |
}); | |
h = h/2; | |
top = top.not; | |
}, { | |
if(left, { | |
l = l + (w/2); | |
}, { | |
bl = l + (w/2); | |
}); | |
w = w/2; | |
left = left.not; | |
}); | |
wins = wins.add(~makeWin.(partial, Rect(bl, bt, w, h))); | |
//Window.new(partial.asString, Rect(bl, bt, w, h)).front; | |
partial = partial+1; | |
hori = hori.not; | |
[partial, [l, t, w, h], [bl, bt, w, h], hori, left, top].postln; | |
} | |
); | |
fork{ | |
loop{ | |
{ | |
wins.do(_.refresh); | |
}.defer; | |
(1/30).wait; | |
} | |
}; | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment