Texture cos(atan2())

var col:int, i:int, j:int, s:int = 500, div:Number =20, outcoord:Point = new Point(), points:Vector.<Point> = new Vector.<Point>();
for (i = 0; i<5; i++) points.push(new Point(int(Math.random()*s),int(Math.random()*s)));
var canvas:Bitmap = Bitmap(addChild(new Bitmap(new BitmapData(s,s, false, 0xFF0000), "auto", true)));
for (i  = 0; i<canvas.width * canvas.height; i++){
	outcoord= new Point( i % canvas.width, i / canvas.width);
	col = 0;
	for (j= 0; j<points.length; j++) col += Math.max(0,255 * Math.cos(Math.atan2(outcoord.y - points[j].y, outcoord.x - points[j].x)*outcoord.x/div) );
	col /= points.length;
    canvas.bitmapData.setPixel(outcoord.x, outcoord.y,  col << 16 |  col << 8 |  col);
}

This is inspired by some stuff I’ve been doing with PixelBender. I think I’m going to convert this to processing to see how fast I can get it to run… will post that over at shapevent. People have been asking me to post swfs…. and I plan on starting to that a little bit… but since this one doesn’t animate, here are a few jpgs:

Leave a Reply

Your email address will not be published. Required fields are marked *