//sclitaire ( var w, wx, wy, mx, my, dragged=false, t, out; mx = MouseX(0, 1024); my = MouseY(0, 768); wx = 128; wy = 264; w = GUIWindow.new("sclitaire", Rect.newBy(wx, wy, 335, 226)).onClose_({ Synth.stop }); x = Array.fill(6, { arg i; var b; b = RangeView.new( w, Rect.newBy(wx.rand, wy.rand, 30, 30), "--", 0.5, 0.0, 0, 1, 0, 'linear'); b.rangeColor = Color.green; b.action = { if(dragged, { x.do({ arg item; if(item.bounds.contains(Point(mx.value-wx,my.value-wy)) & (item !== b), { b.backColor = Color.green; t.triggerSynth(Synth.new({ Cutoff.ar(Pulse.ar(1500 , 0.5, 0.1), 0.02) }) ); }); }) }); dragged = dragged.not; Task({ while({dragged}, { b.bounds = b.bounds.moveTo( mx.value-wx-(b.bounds.width/2), my.value-wy-(b.bounds.height/2) ).resizeBy(1.rand2, 1.rand2); b.backColor = Color.new(rrand(120, 180), rrand(120, 180), rrand(120, 180)); b.value = b.value + 0.01 % 1; 0.02.wait; }) }); }; }); Synth.play({ Task({ loop({ w.refresh; 0.02.wait; }) }); out = TSpawn.ar(nil, 1); t = out.source; out; }); w.close; ) ****/* authors so far: jrh 02 */ |