View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide

delayed easter greetings

this example lets you search for easter eggs on the keyboard. well.
//____________________Delayed Easter Greetings
(
var nx, ny, w, a, plug, trig, c;
var many, where, ei, k, key, dict, surprise, alert, s=0;
nx = 1024;
ny = 768;

many = 0.1;
where = Array.fill(100, { if (0.3.coin, { 1 }, {0}) });

ei = 0;
k =  0;
key = [ $1, $2, $3, $4, $5, $6, $7, $8, $9, $0, $q, $w, $e, $r, $t, $z, $u, $i, $o, $p, $a, $s, $d, $f, $g, $h, $j, $k, $l, $y, $x, $c, $v, $b, $n, $m].scramble;
dict = IdentityDictionary.new;

key.do({ arg item; 
		var x;
		x = where.choose;  
		dict.add(item -> x)
	});

c = Color.new(135, 145, 215);
w = GUIWindow.new("panel", Rect.newBy(0, 0, nx+50, ny+50)).backColor_(c);

alert = GUIWindow.new("egg!", Rect.newBy(707, 227, 120, 115)).hide;



a  = ScopeView.new( w, Rect.new(300, 300, 340, 340), 4410/16, -1, 1);
a.focus;
a.keyDownAction = { arg ascii; 
				var x0, y0, d, rect; 
				
				x0 = rrand(0, nx);
				y0 = rrand(0, ny);
				d = rrand(30, 40);
				
				s = dict.at(ascii);
				//s = 1;  //cheat;
				
				if(s.isNil, { s = 0 });
				if(s == 0, {  w.backColor_(c); /*alert.hide*/ });  
				if(s == 1, {	 w.backColor_(Color.new(255.rand, 255.rand, 255.rand)); 
							alert.backColor_(Color.new(255.rand, 255.rand, 255.rand)).show.toFront;
							Task.new({ 1.wait; alert.hide }); 
							d = 80;  
							dict.put(ascii, 0)  });
				
					
				rect = Rect.new(x0, y0, x0+d, y0+d);
				a.bounds_(rect);
				w.refresh;
				
			
				trig.gate(0.1);
			};
			
			
surprise = [	{ var a, e;
		
		EnvGen.kr(Env.perc(0.02, 1.5+1.rand2, 1, -4)) * Pan2.ar(Resonz.ar(Crackle.ar(1.95+0.03.rand2, 0.5), 1500+400.rand2, 0.6), 1.rand2) ;
				},
			{ var a, e;
		e = Env.perc(0.2+0.19.rand2, 4.3.rand, 0.1, -6);
		a = Lag.ar(LFNoise2.ar(1.0.rand, 4.1.rand*100, 500+400.rand2), 1.0.rand/3);
		Pan2.ar(Mix.ar(SinOsc.ar([1, 5, 3]*a, 0, EnvGen.kr(e)), Line.kr(0, [-1, 1].choose)));
					}
	];
Synth.play({ 
	var out, m; 
		trig = Plug.ar(0);
		m = LFNoise1.kr(0.2, 1, 3);
		Scope.ar(a,
		
			out = TSpawn.ar({ surprise.at(s.asInteger).value }, 2, nil, trig > 0);
			CombL.ar(out, 1.6, 0.4*m, 4, 1, out)
			)
	
		});
w.close;
alert.close;
)

/*
authors so far:
jrh 01
*/


Link to this Page