Skip to content

Instantly share code, notes, and snippets.

@banthar
Created March 16, 2010 10:33
Show Gist options
  • Save banthar/333829 to your computer and use it in GitHub Desktop.
Save banthar/333829 to your computer and use it in GitHub Desktop.
pollock
// haxe -lib neash -main Main -swf9 pollock.swf
import flash.display.Sprite;
import flash.display.Shape;
import flash.display.Stage;
import flash.display.StageScaleMode;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.geom.Point;
class Main extends Bitmap
{
var lastX:Float;
var lastY:Float;
public function new()
{
super();
flash.Lib.current.stage.addEventListener(MouseEvent.MOUSE_MOVE,mouseMove);
flash.Lib.current.stage.addEventListener(Event.RESIZE,resize);
}
private function mouseMove(event:MouseEvent)
{
var l=Point.distance(new Point(mouseX,mouseY),new Point(lastX,lastY));
var shape=new Shape();
if(l<3 && Math.random()<0.25)
{
shape.graphics.beginFill(0);
shape.graphics.drawCircle(mouseX,mouseY,24*Math.random());
shape.graphics.endFill();
}
if(Math.random()<0.05)
{
shape.graphics.beginFill(0);
shape.graphics.drawCircle(mouseX+82*(Math.random()-0.5),mouseY+82*(Math.random()-0.5),4*Math.random());
shape.graphics.endFill();
}
shape.graphics.lineStyle(16-l);
shape.graphics.moveTo(lastX,lastY);
shape.graphics.lineTo(mouseX,mouseY);
bitmapData.draw(shape);
lastX=mouseX;
lastY=mouseY;
}
public function resize(?event:Event)
{
bitmapData=new BitmapData(stage.stageWidth,stage.stageHeight);
}
static public function main()
{
haxe.Log.trace = function(v,?pos) { untyped __global__["trace"](v); }
var stage=flash.Lib.current.stage;
stage.scaleMode=StageScaleMode.NO_SCALE;
var main=new Main();
stage.addChild(main);
main.resize();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment