package { import flash.display.Sprite; import flash.display.Graphics; import flash.events.Event; import flash.events.MouseEvent; [SWF(backgroundColor=0xffffff)] public class actionscript_extra_paint extends Sprite { private var new_size_influence:Number = 0.5; private var mid_point_push:Number = .75; private var max_line_width:Number = (Math.random() * 10) + 10; //private var info.visible:Boolean = false; private var curves:Array; private var start_x:Number; private var start_y:Number; private var mid_x:Number; private var mid_y:Number; private var end_x:Number; private var end_y:Number; private var with_wii:int = 0; private var distance:Number; private var new_size:Number; private var parity:Boolean; private var size:Number = 0; private var color:uint = 0x000000; private var aggression:Number = 5.4; // 12.4;//3.4; public function actionscript_extra_paint() { init(); } private function init():void { graphics.lineStyle(1); start_x = mid_x = end_x = stage.stageWidth / 2; start_y = mid_y = end_y = stage.stageHeight / 2; addEventListener(Event.ENTER_FRAME, paint); stage.addEventListener(MouseEvent.CLICK, onMouseClick); //stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown); //stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp); } private function onMouseClick(event:MouseEvent):void{ color = Math.random() * 0xFFFFFF; //txt.text = "Color: 0x" + color.toString(); } private function onMouseDown(event:MouseEvent):void { graphics.moveTo(mouseX, mouseY); stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove); } private function onMouseUp(event:MouseEvent):void { stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove); } private function onMouseMove(event:MouseEvent):void { //graphics.lineTo(mouseX, mouseY); paint(event); } public function paint(event:Event):void { //counter++; //txt.text = counter.toString(); //if (with_wii == 0) { //vpX = mouseX; //vpY = mouseY; //} //AE //graphics.lineTo(mouseX, mouseY); /** * * The code for the paint function was ported and adapted from: * "Splatter", by Stamen Design * http://stamen.com/projects/splatter * **/ mid_x = ((end_x - start_x) * (1 + mid_point_push)) + start_x; mid_y = ((end_y - start_y) * (1 + mid_point_push)) + start_y; start_x = end_x; start_y = end_y; //end_x = vpX;// = mouseX; //end_y = vpY;// = mouseY; end_x = mouseX; end_y = mouseY; distance = Math.sqrt(Math.pow((end_x - start_x), 2) + Math.pow((end_y - start_y), 2)); new_size = max_line_width / distance; size = aggression*new_size;//(new_size_influence * new_size) + ((1 - new_size_influence) * size); splat(graphics, start_x, start_y, end_x, end_y, mid_x, mid_y, size); parity = false; /* _parent.new_size_influence += ((Math.random() * 0.1) - 0.05); _parent.mid_point_push += ((Math.random() * 0.1) - 0.05); _parent.max_line_width += ((Math.random() * 4) - 2); */ new_size_influence += ((Math.random() * 0.1) - 0.05); mid_point_push += ((Math.random() * 0.1) - 0.05); max_line_width += ((Math.random() * 4) - 2); } private function splat(obj:Graphics, x1:Number, y1:Number, x2:Number, y2:Number, x3:Number, y3:Number, d:Number):void { //var obj:Graphics = painting.graphics; obj.lineStyle(d, color, 100); //txt.text = d.toString(); obj.moveTo(x1, y1); obj.curveTo(x3, y3, x2, y2); //curves.push([x1, y1, x3, y3, x2, y2, d]); // splotch var dd:Number = Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2)); for (var i:uint = 0; i