curveToで遊ぶ
/**
* Copyright Nyarineko ( http://wonderfl.net/user/Nyarineko )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/vEry
*/
package{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Point;
import flash.geom.ColorTransform;
import frocessing.color.ColorHSV;
[SWF(width = "465", height = "465", backgroundColor = "0x000000", frameRate = "30")]
public class Main extends Sprite{
public var _vParticles:Vector.<Point>;
static private const OBJ_MAX:Number = 40;
private var colorTrans:ColorTransform;
private var color:ColorHSV;
public function Main():void{
_vParticles = new Vector.<Point>(OBJ_MAX, true);
for(var i:uint = 0;i < OBJ_MAX;i++){
var p:Point = new Point(230,230);
_vParticles[i] = p;
}
color = new ColorHSV(0, 1);
colorTrans = new ColorTransform();
colorTrans.color = color.value;
transform.colorTransform = colorTrans;
stage.addEventListener(MouseEvent.MOUSE_MOVE,moveMouse);
stage.addEventListener(Event.ENTER_FRAME,enFrame);
}
private function moveMouse(e:MouseEvent):void{
var p:Point = new Point(mouseX,mouseY);
_vParticles[0] = p;
}
private function enFrame(e:Event):void{
color.h ++;
colorTrans.color = color.value;
transform.colorTransform = colorTrans;
graphics.clear();
graphics.moveTo(_vParticles[0].x,_vParticles[0].y);
//この辺弄るといろいろおもしろい
for(var i:uint = 1;i < OBJ_MAX - 1;i++){
graphics.lineStyle(1,0xffffff,1-(i/OBJ_MAX),true,"normal");
for(var j:uint = 1;j < 10;j++){
var a:Number = j * i * (mouseX - 230)/80;
var b:Number = j * i * (mouseX - 230)/80;
graphics.moveTo(_vParticles[i-1].x + (_vParticles[i].x - _vParticles[i-1].x)/2 + a,
_vParticles[i-1].y + (_vParticles[i].y - _vParticles[i-1].y)/2 + b);
graphics.curveTo(
_vParticles[i].x,
_vParticles[i].y,
_vParticles[i].x + (_vParticles[i+1].x - _vParticles[i].x)/2 + a,
_vParticles[i].y + (_vParticles[i+1].y - _vParticles[i].y)/2 + b);
}
}
for(var p:uint = OBJ_MAX - 1;p > 0;p--){
_vParticles[p].x = _vParticles[p-1].x;
_vParticles[p].y = _vParticles[p-1].y ;
}
}
}
}