うごうご
アレ
package{
import flash.display.Sprite;
import flash.display.Graphics;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.geom.Point;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.filters.ColorMatrixFilter;
import flash.text.TextField;
[SWF(width="465",height="465",backgroundColor="0x000000",frameRate="30")]
public class Ugo extends Sprite{
private var p:Vector.<Point>;
private var d:UgoDrawer;
private var canvas:Sprite;
private var f:Boolean;
private var c:int;
private var bmp:Bitmap;
private var bmd:BitmapData;
private var cmf:ColorMatrixFilter;
private var clearButton:TextField;
public function Ugo(){
p=new Vector.<Point>();
canvas=new Sprite();
d=new UgoDrawer(canvas);
d.p=p;
var g:Graphics=graphics;
g.beginFill(0xffc000);
g.drawRect(0,0,465,465);
g.endFill();
c=0;
f=false;
bmd=new BitmapData(1920,1080,true,0x00000000);
bmp=new Bitmap(bmd);
bmp.x=bmp.y=6;
addChild(bmp);
addChild(canvas);
cmf=new ColorMatrixFilter([1,0,0,0,128,0,1,0,0,96,0,0,1,0,0,0,0,0,1,0]);
clearButton=new TextField();
clearButton.text="clear";
clearButton.textColor=0xffffff;
clearButton.background=true;
clearButton.backgroundColor=0x000000;
clearButton.width=30;
clearButton.height=20;
clearButton.selectable=false;
addChild(clearButton);
Wonderfl.capture_delay(10);
clearButton.addEventListener(MouseEvent.CLICK,clear);
stage.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler);
stage.addEventListener(MouseEvent.MOUSE_UP,mouseUpHandler);
addEventListener(Event.ENTER_FRAME,enterFrameHandler);
}
private function clear(event:MouseEvent):void{
p=new Vector.<Point>();
d.p=p;
d.reflesh();
}
private function mouseDownHandler(event:MouseEvent):void{
f=true;
c=0;
}
private function mouseUpHandler(event:MouseEvent):void{
p.push(null);
f=false;
}
private function enterFrameHandler(event:Event):void{
d.reflesh();
if(c%2==0&&f){
p.push(new Point(mouseX,mouseY));
c=0;
}
c++;
bmd.fillRect(bmd.rect,0x00000000);
bmd.draw(canvas);
bmd.applyFilter(bmd,bmd.rect,new Point(0,0),cmf);
}
}
}
import flash.display.Sprite;
import flash.display.Graphics;
import flash.geom.Point;
class UgoDrawer{
private var _target:Sprite;
public var p:Vector.<Point>;
public var m:Number=4;
public function UgoDrawer(target:Sprite){
_target=target;
p=new Vector.<Point>();
}
public function reflesh():void{
var g:Graphics=_target.graphics;
g.clear();
g.lineStyle(12,0x000000);
var l:int=p.length;
var sp:Point;
for(var i:int=0;i<l;i++){
if(p[i]==null){
sp=null;
}
else{
if(sp==null){
sp=p[i];
g.moveTo(p[i].x+Math.random()*(2*m+1)-m,p[i].y+Math.random()*(2*m+1)-m);
}
else{
g.lineTo(p[i].x+Math.random()*(2*m+1)-m,p[i].y+Math.random()*(2*m+1)-m);
}
}
}
}
}