forked from: forked from: Blur Circle
なぜかクリックしないと描画されない><
-> 別のマシンだと動いた
@author ll_koba_ll (RAWHIDE.)
// forked from hacker_9yatosct's forked from: Blur Circle
// forked from ll_koba_ll's Blur Circle
// write as3 code here..
package
{
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.filters.*;
// なぜかクリックしないと描画されない><
// -> 別のマシンだと動いた
[SWF(frameRate="60", backgroundColor="#000000")]
/**
*
* @author ll_koba_ll (RAWHIDE.)
*/
public class Rotationlight extends Sprite
{
private var blur:BlurFilter;
private var container:Sprite;
private var source:Sprite;
private var bmpd:BitmapData;
private var _cTra:ColorTransform;
private var _currentColor:int;
private var _particles:Array;
public function Rotationlight()
{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.quality = StageQuality.BEST;
init();
addEventListener(Event.ENTER_FRAME, update);
stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownEvent);
}
private function mouseDownEvent(event:MouseEvent):void {
_currentColor = Math.random()*0xFFFFFF;
_cTra = new ColorTransform(Math.random(), Math.random(), Math.random(), 1.0);
}
private function init():void
{
_cTra = new ColorTransform(Math.random(), Math.random(), Math.random(), 1.0);
_currentColor = 0x9FFF0F;
_particles = [];
trace(stage.stageWidth)
blur = new BlurFilter(2,2);
bmpd = new BitmapData(500, 500, false, 0x000000);
container = new Sprite();
source = new Sprite();
addChild(new Bitmap(bmpd));
container.addChild(source);
}
private function update(e:Event = null):void
{
for(var i:Number = 0; i < 30; i++){
//addCircle();
createParticle();
}
var _rect:Rectangle = new Rectangle(0,0,500,500);
bmpd.draw(container, null, null, BlendMode.ADD);
var z:int = _particles.length;
while(z--){
var p:Particle = _particles[z];
p.vx *= .9;
p.vy *= .9;
p.x += p.vx;
p.y += p.vy;
bmpd.setPixel32(p.x, p.y, _currentColor);
if(p.x > stage.stageWidth || p.x < 0 || p.y > stage.stageHeight || Math.abs(p.vx) < .01 || Math.abs(p.vy) < .01){
_particles.splice(z,1);
}
}
// bmpd.colorTransform(_rect, _cTra);
addCircle();
bmpd.applyFilter(bmpd, bmpd.rect, new Point(), blur);
source.x = mouseX;
source.y = mouseY;
}
private function createParticle():void{
var p:Particle = new Particle();
p.x = mouseX;
p.y = mouseY;
var radius:Number = Math.sqrt(Math.random())*10;
var angle:Number = Math.random()*Math.PI*2;
p.vx = Math.random()*3*Math.cos(angle) * radius;
p.vy = Math.random()*3* Math.sin(angle) * radius;
_particles.push(p);
}
private function addCircle():void{
with(source.graphics)
{
clear();
beginFill(_currentColor);
drawCircle(0,0,5);
endFill();
}
}
}
}
class Particle {
public var x:Number = 0;
public var y:Number = 0;
public var vx:Number = 0;
public var vy:Number = 0;
public var c:Number = 0;
public function Particle(){}
}