Toggle navigation
Sign Up
Log In
Explore
Works
Folders
Tools
Collections
Artists
Groups
Groups
Topics
Tasks
Tasks
Jobs
Teams
Jobs
Recommendation
More Effects...
ActionScript
// forked from Kwoon's ActionPainting package { import flash.filters.DisplacementMapFilterMode; import flash.filters.DisplacementMapFilter; import flash.filters.BlurFilter; import flash.display.*; import flash.events.*; import flash.geom.*; public class ActionPainting extends Sprite { private const WIDTH:int = 600; private const HEIGHT:int = 600; private var pArr:Array = []; private var container:Sprite = new Sprite(); private var bmpd:BitmapData = new BitmapData(WIDTH, HEIGHT, true, 0x0); private var bmp:Bitmap = new Bitmap(bmpd); private var blurFilter:BlurFilter = new BlurFilter(2.2, 2.2, 2); private var rect:Rectangle = new Rectangle(0, 0, WIDTH, HEIGHT); private var point:Point = new Point(); private var redOffset:int = Math.random()*300 - 100; private var greenOffset:int = Math.random()*300 - 100; private var blueOffset:int = Math.random()*300 - 100; private var cTr:ColorTransform = new ColorTransform(1, 1, 1, 1, redOffset, greenOffset, blueOffset); //private var snd:C3_C = new C3_C(); public function ActionPainting() { stage.scaleMode = StageScaleMode.NO_SCALE; this.graphics.beginFill(0xfffffff); this.graphics.drawRect(0, 0, WIDTH, HEIGHT); this.graphics.endFill(); addPtc(); var map:BitmapData = new BitmapData(WIDTH, HEIGHT); map.perlinNoise(84, 84, 5, Math.random()*100, false, true, 1, true); bmp.filters = [new DisplacementMapFilter(map, point, 1, 1, 64, 64, DisplacementMapFilterMode.CLAMP)]; addEventListener(Event.ENTER_FRAME, enterFrame); stage.addEventListener(MouseEvent.CLICK, mouseClick); } private function addPtc():void{ var pCount:uint = 8; while(pCount--){ var p:Ptc = new Ptc(6+Math.random()*14); p.x = int(Math.random()*WIDTH); p.y = int(Math.random()*HEIGHT); container.addChild(p); pArr.push(p); } addChild(bmp); } private function enterFrame(evt:Event):void { var mx:Number=0, my:Number=0; var num:uint = pArr.length; for(var i:int =0 ; i < num; ++i){ var p:Ptc = pArr[i]; p.process(); mx += p.x / WIDTH; my += p.y / HEIGHT; } //snd.r0 = mx/8; //snd.r1 = my/8; /* if(redOffset !== cTr.redOffset){ (redOffset>cTr.redOffset)?(cTr.redOffset++):(cTr.redOffset--); }else{ redOffset = Math.random()*300 - 100; } if(greenOffset !== cTr.greenOffset){ (greenOffset>cTr.greenOffset)?(cTr.greenOffset++):(cTr.greenOffset--); }else{ greenOffset = Math.random()*300 - 100; } if(blueOffset !== cTr.blueOffset){ (blueOffset>cTr.blueOffset)?(cTr.blueOffset++):(cTr.blueOffset--); }else{ blueOffset = Math.random()*300 - 100; }*/ bmpd.draw(container); bmpd.applyFilter(bmpd, rect, point, blurFilter); //bmp.transform.colorTransform = cTr; } private function mouseClick(evt:MouseEvent):void{ for(var i:String in pArr){ pArr[i].stopFlag = false; pArr[i].destPoint.x = evt.stageX; pArr[i].destPoint.y = evt.stageY; } } } } import flash.events.Event; import flash.display.BlendMode; import flash.geom.Point; import flash.display.Shape; class Ptc extends Shape{ public var destPoint:Point = new Point(); private var vx:Number = 0; private var vy:Number = 0; private var easing:Number = 0.02 + Math.random()*0.03; private var rNum:int; public var stopFlag:Boolean = false; public function Ptc(radius:Number){ this.graphics.beginFill(0x0); this.graphics.drawCircle(0, 0, radius); this.graphics.endFill(); this.blendMode = BlendMode.LIGHTEN; } public function process():void{ if(stopFlag){ rNum = Math.random()*20; if(rNum == 0){ destPoint.x = Math.random()*553 - 20; destPoint.y = Math.random()*553 - 20; stopFlag = false; } }else{ movePtc(); if(Math.round(vx)==0 && Math.round(vy)==0){ stopFlag = true; } } } private function movePtc():void{ vx = (destPoint.x - this.x)*easing; vy = (destPoint.y - this.y)*easing; this.x += vx; this.y += vy; } }
Join Effecthub.com
Working with Global Gaming Artists and Developers!
Login
Sign Up
Or Login with Your Email Address:
Email
Password
Remember
Or Sign Up with Your Email Address:
Your Email
This field must contain a valid email
Set Password
Password should be at least 1 character
Stay informed via email