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

redFrik drawings

Home   How To   Code Pool   Public Library   Theory   Events
//"distance and angles alternatively" - with inspiration from p.dahlstedt sounds unheard of: mutasynth
(
	var w, u, p, width= 400, height= 400, l, center, cnt= 0, scale= 5, scalef= 0.02.rand2;
	center= Point(width, height)/2;
	w= Window("ga plot test", Rect(128, 64, width, height), false);
	u= UserView(w, Rect(0, 0, width, height));
	u.background= Color.white;
	w.front;
	l= {1.0.rand}.dup(20000);
	u.drawFunc= {
		cnt= cnt+1;
		if(cnt%25==0, {
			scalef= 0.02.rand2;
			800.do{l.put(l.size.rand, 1.0.rand)};
		});
		scale= (scale+scalef).wrap(-10, 10);
		p= Point(0, 0);
		Pen.moveTo(center);
		l.clump(2).do{|ll, i|
			var distance, angle;
			#distance, angle= ll;
			p= Point(distance, distance).rotate(angle*2pi)+p;
			Pen.lineTo(p*scale+center);
		};
		Pen.stroke;
	};
	{while{w.isClosed.not} {u.refresh; (1/25).wait}}.fork(AppClock);
)


//ga plot test gone wrong /redFrik
(
	var w, u, p, width= 400, height= 400, l;
	l= {1.0.rand}.dup(20000);
	p= Point(0, 0);
	w= Window("ga plot test", Rect(128, 64, width, height), false);
	u= UserView(w, Rect(0, 0, width, height));
	u.background= Color.white;
	w.front;
	u.drawFunc= {
		Pen.moveTo(Point(width/2, height/2));
		l.clump(2).do{|ll, i|
			var distance, angle;
			#distance, angle= ll;
			p= Point(distance, distance).rotate(angle*2pi)+p;
			Pen.lineTo(Point(p.x*10+(width/2)%width, p.y*10+(height/2)%height));
		};
		Pen.stroke;
	};
)


(
	var width= 640, height= 480, run= true, w, u, theta= 0, drawFunc, asdf= 0, cnt= 0;
	w= Window("trail test2", Rect(128, 64, width, height), false);
	drawFunc= {|v|
		var x= 105*sin(theta), y= 25*cos(asdf);
		
		//--clear with alpha
		Pen.fillColor= Color.grey(0, sin(cnt%1000/1000).linexp(-1, 1, 0.001, 1));
		Pen.fillRect(Rect(0, 0, width, height));
		cnt= cnt+1;
		
		//--rects
		Pen.strokeColor= Color.white;
		Pen.push;
		Pen.translate(width*0.5, height*0.5);
		8.do{|i|		//number of boxes
			Pen.scale(asdf*4+(i*0.4), 0.5+((i/3).sqrt));
			Pen.rotate(asdf+theta);
			Pen.strokeRect(Rect.aboutPoint(Point(x, y), 60, 40));
		};
		Pen.pop;
	};
	u= UserView(w, Rect(10, 10, width-20, height-20))
		.clearOnRefresh_(false)
		.drawFunc_(drawFunc)
		.background= Color.black;
	w.front;
	Routine({
		var i= 0;
		while({w.isClosed.not}, {
			asdf= sin(i%900/900*2pi)*0.1;
			theta= theta+0.01;
			u.refresh;
			(1/40).wait;
			i= i+1;
		});
	}).play(AppClock)
)


//sunday drawings /f0
(
	var width= 640, height= 480, w, u, drawFunc, clear= true;
	var a, b, c, d, e, f, g, phasor, theta= 0;
	w= Window("sunday drawings", Rect(128, 64, width, height), false);
	drawFunc= {|v|
		var x, y;
		if(clear, {
			theta= 0;
			a= 200.rand;
			b= 200.rand;
			c= 3.0.rand2;
			d= 3.0.rand2;
			e= 3.0.rand;
			f= 0.1.rrand(1.5)*#[1, -1].choose;
			g= 0.1.rrand(1.5)*#[1, -1].choose;
			Pen.fillColor= Color.grey(0, 0.1);
			Pen.fillRect(Rect(0, 0, width, height));
		}, {
			x= sin(theta*a%a/b*c*2pi);
			y= sin(theta*b%b/a*d*2pi);
			Pen.strokeColor= Color.grey(phasor, 0.5);
			Pen.translate(width*0.5, height*0.5);
			Pen.scale(f, g);
			Pen.rotate(theta);
			switch(a%3,
				0, {Pen.strokeOval(Rect.aboutPoint(Point(x*100, y*100), a, b))},
				1, {Pen.strokeRect(Rect.aboutPoint(Point(x*100, y*100), a, b))},
				2, {Pen.line(Point(x*100, y*100), Point(a*c*100, b*d*100)); Pen.stroke}
			);
		});
	};
	u= UserView(w, Rect(0, 0, width, height))
		.clearOnRefresh_(false)
		.drawFunc_(drawFunc)
		.background_(Color.black);
	w.front;
	Routine({
		var i;
		0.1.wait;
		while({w.isClosed.not}, {
			clear= false;
			i= 0;
			while({w.isClosed.not and:{i<750}}, {
				theta= theta+(d*e*f);
				phasor= i/750;
				u.refresh;
				0.0001.wait;
				i= i+1;
			});
			3.wait;
			clear= true;
			i= 0;
			while({w.isClosed.not and:{i<50}}, {
				u.refresh;
				0.02.wait;
				i= i+1;
			});
		});
	}).play(AppClock)
)


Link to this Page