forked from: forked from: forked from: 光るリボン(Ribbon Light)
Copyright 12346 ( http://wonderfl.net/user/12346 )
MIT License ( http://www.opensource.org/licenses/mit-license.php )
Downloaded from: http://wonderfl.net/c/dAf0
/**
* Copyright Nos_lkSsvOhB ( http://wonderfl.net/user/Nos_lkSsvOhB )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/lcIh
*/
// forked from Nosuke_lkSsvOhB's forked from: forked from: forked from: 光るリボン(Ribbon Light)
// forked from Nosuke_lkSsvOhB's forked from: forked from: 光るリボン(Ribbon Light)
// forked from mousepancyo's 光るリボン(Ribbon Light)
// forked from nutsu's SketchSample6
package {
import flash.display.Sprite;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.events.Event;
import flash.filters.BlurFilter;
import flash.geom.Point;
import flash.geom.ColorTransform;
[SWF(width=465,height=465,backgroundColor=0x000000,frameRate=60)]
public class Main extends Sprite{
private const WIDTH:Number = 465;
private const HEIGHT:Number = 465;
private var _sketch:CurveSketch;
private var _bmd:BitmapData;
private var _bm:Bitmap;
private var _container:Sprite = new Sprite();
public function Main() {
graphics.beginFill(0)
graphics.drawRect(0, 0, WIDTH, HEIGHT)
graphics.endFill()
addChild(_container);
//
_sketch = new CurveSketch();
_bmd = new BitmapData(WIDTH, HEIGHT, true, 0);
_container.addChild(_sketch);
_container.addChild(_bm = new Bitmap(_bmd) as Bitmap);
_bm.blendMode = "add";
//
addEventListener(Event.ENTER_FRAME, update);
}
private function update(e:Event):void{
_bmd.applyFilter(_bmd, _bmd.rect, new Point(), new BlurFilter(10,10,1));
_bmd.draw(_sketch, null, null, "add");
}
}
}
//package {
import frocessing.display.F5MovieClip2D;
import frocessing.geom.FGradientMatrix;
import frocessing.color.ColorHSV
class CurveSketch extends F5MovieClip2D
{
//加速度運動の変数
//位置
private var xx:Number;
private var yy:Number;
//速度
private var vx:Number;
private var vy:Number;
//加速度の係数
private var ac:Number;
//速度の減衰係数
private var de:Number;
private var mx:Number=0;
private var my:Number=0;
private var r:Number=200;
private var tt:Number=0;
private var ti:Number=0;
private var i:int=0;
private var j:Number=16;
private var dx:Number=0;
private var dy:Number=0;
private var ax:Array=[199,280,68,330,118,199];
private var ay:Array=[75,324,169,169,324,75];
private var ts:Array=[j,j,j,j,j];
//描画座標
private var px0:Array;
private var py0:Array;
private var px1:Array;
private var py1:Array;
private var t:Number = 0
//描画グループ
private var shapes:Array;
public function CurveSketch()
{
//初期化
vx = vy = 0.0;
mx = ax[i];
my = ay[i];
xx = mx;
yy = my;
ac = 0.06;
de = 0.9;
px0 = [xx, xx, xx, xx];
py0 = [yy, yy, yy, yy];
px1 = [xx, xx, xx, xx];
py1 = [yy, yy, yy, yy];
shapes = [];
//線と塗りの色指定
noStroke();
}
public function draw():void
{
if(ti<=500){
if(i<=4){
dx=(ax[i+1]-ax[i])/ts[i];
dy=(ay[i+1]-ay[i])/ts[i];
mx=ax[i]+dx*(ti-tt);
my=ay[i]+dy*(ti-tt);
if(ti==tt+ts[i]){
tt=ti;
i+=1;
}
}else{
i=0;
}
//加速度運動
xx += vx += ( mx - xx ) * ac;
yy += vy += ( my - yy ) * ac;
var len:Number = mag( vx, vy );
//新しい描画座標
var x0:Number = xx + 1 + len * 0.01;
var y0:Number = yy - 1 - len * 0.01;
var x1:Number = xx - 1 - len * 0.01;
var y1:Number = yy + 1 + len * 0.01;
//描画座標
px0.shift(); px0.push( x0 );
py0.shift(); py0.push( y0 );
px1.shift(); px1.push( x1 );
py1.shift(); py1.push( y1 );
var _px0:Array = [px0[0], px0[1], px0[2], px0[3]];
var _py0:Array = [py0[0], py0[1], py0[2], py0[3]];
var _px1:Array = [px1[0], px1[1], px1[2], px1[3]];
var _py1:Array = [py1[0], py1[1], py1[2], py1[3]];
shapes.push( { px0:_px0, py0:_py0, px1:_px1, py1:_py1, mtx:null} );
if (shapes.length >= 100) shapes.shift();
var shapesLength:int = shapes.length;
for (var k:int = shapesLength-1; k >= 0; k--)
{
var sh:Object = shapes[k];
var color:ColorHSV = new ColorHSV(t, 0.8, 1, 0.1)
t += 0.005;
beginFill(int(color), 0.2)
beginShape();
curveVertex( sh.px0[0], sh.py0[0] );
curveVertex( sh.px0[1], sh.py0[1] );
curveVertex( sh.px0[2], sh.py0[2] );
curveVertex( sh.px0[3], sh.py0[3] );
vertex( sh.px1[2], sh.py1[2] );
curveVertex( sh.px1[3], sh.py1[3] );
curveVertex( sh.px1[2], sh.py1[2] );
curveVertex( sh.px1[1], sh.py1[1] );
curveVertex( sh.px1[0], sh.py1[0] );
endShape();
}
//減衰処理
vx *= de;
vy *= de;
// ti+=1;
// mx+=1;
// my+=1;
}else if(ti>=600){
tt=0;
ti=0;
i=0;
vx = vy = 0.0;
mx = ax[i];
my = ay[i];
xx = mx;
yy = my;
px0 = [xx, xx, xx, xx];
py0 = [yy, yy, yy, yy];
px1 = [xx, xx, xx, xx];
py1 = [yy, yy, yy, yy];
shapes = [];
}
ti++;
}
}
//}