Actionscript:
-
stage.frameRate = 30;
-
-
var imageNum:int = 10000;
-
var point:Point = new Point(0,0);
-
var s:Sprite = new Sprite();
-
s.graphics.beginFill(0xCCCCCC);
-
s.graphics.lineStyle(0,0x000000);
-
s.graphics.drawCircle(3,3,3);
-
s.alpha = .1;
-
-
var nested:Sprite = new Sprite();
-
nested.addChild(s);
-
var image:BitmapData = new BitmapData(s.width, s.height, true, 0x00000000);
-
image.draw(nested);
-
-
var canvas:BitmapData = new BitmapData(400,400, true, 0xFFFFFFFF);
-
addChild(new Bitmap(canvas));
-
-
var xPos:Array = new Array();
-
var yPos:Array = new Array();
-
for (var i:int = 0; i<imageNum; i++) {
-
xPos.push(Math.random()*400);
-
yPos.push(Math.random()*400);
-
}
-
-
addEventListener(Event.ENTER_FRAME, onLoop);
-
function onLoop(evt:Event):void {
-
canvas.fillRect(new Rectangle(0,0,400,400), 0xFFFFFFFF);
-
var div:Number;
-
for (var i:int = 0; i<imageNum; i++) {
-
div = (i / 100)+2;
-
xPos[i] += (mouseX - xPos[i])/div;
-
yPos[i] += (mouseY - yPos[i])/div;
-
point.x = xPos[i];
-
point.y = yPos[i];
-
canvas.copyPixels(image, image.rect, point, null, null, true);
-
}
-
}
This is from my other blog but I figured it was worth posting here. It draws 10'000 transparent circles that each follow the mouse at different speeds. This is achieved using copyPixels().
2 Comments
Actually I was wondering what happened to your other blog… I was following its updates and thought it was very inspirational.
Hey Dimitree… actually my other blog will be back up online soon - the site is down temporarily, in the next week or so it will be back up with new content…