LineWorks
/**
* Copyright _mutast ( http://wonderfl.net/user/_mutast )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/b5I7
*/
package
{
import flash.display.Graphics;
import flash.display.Sprite;
import flash.events.Event;
import flash.filters.GlowFilter;
[SWF(width="465", height="465", backgroundColor="#000000", frameRate=60)]
public class Index extends Sprite {
var ChaseList:Array;
var lines:int = 18;
var lineP:int = 20;
var filter:GlowFilter;
var colorList:Array = [0x5E4A2F,0xC4AE59,0x775C2B]
public function Index() {
ChaseList = new Array();
for (var i:int = 0; i < lines; i++) {
var List:Array = new Array();
for (var j:int = 0; j < lineP; j++) {
var P:ChaseP = new ChaseP();
List.push(P);
}
ChaseList.push(List);
}
for (i = 0; i < lines; i++) {
P = ChaseList[i][0];
var randamP:Rand = new Rand(this, P);
}
addEventListener(Event.ENTER_FRAME, loop);
filter = new GlowFilter(0x766D30, 0.5);
this.filters = [filter];
}
public function loop(evt:Event):void {
graphics.clear();
for (var i:int = 0; i < lines; i++) {
var List:Array = ChaseList[i];
var a1:ChaseP = List[0];
var a2:ChaseP = List[1];
moveP(a1, a2, 0.02, 0.8);
var p:uint = colorList[i % colorList.length];
var alh:Number = 0.6;
var Thick:Number = 4;
for (var j:int = 2; j <lineP ; j++) {
var a3:ChaseP = List[j - 1];
var a4:ChaseP = List[j];
moveP(a3, a4, 0.3, 0.4);
graphics.lineStyle(Thick, p, alh);
graphics.moveTo(a3.x, a3.y);
graphics.lineTo(a4.x, a4.y);
alh -= 0.03;
Thick -= 0.3;
}
}
}
public function moveP(p0:ChaseP, p1:ChaseP, num1:Number, num2:Number) {
var point0:ChaseP = p0;
var point1:ChaseP = p1;
var Spring:Number = num1;
var Dis:Number = num2;
point1.vx += (point0.x - point1.x) * num1;
point1.vx *= num2;
point1.x += point1.vx;
point1.vy += (point0.y - point1.y) * num1;
point1.vy *= num2;
point1.y += point1.vy;
}
}
{
}
}
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.events.TimerEvent;
import flash.utils.Timer;
class ChaseP {
var x:Number;
var y:Number;
var vx:Number;
var vy:Number;
public function ChaseP() {
x = 0;
y = 0;
vx = 0;
vy = 0;
}
}
class Rand extends Sprite {
var dis:DisplayObject;
var cp:ChaseP;
var timer:Timer;
var move:int = 100;
public function Rand(disp:DisplayObject, p:ChaseP) {
dis = disp;
cp = p;
timer = new Timer(0);
timer.addEventListener(TimerEvent.TIMER, loop);
timer.start();
function loop(evt:TimerEvent):void {
cp.x = Math.random() * move - move / 2 + dis.mouseX;
cp.y = Math.random() * move - move / 2 + dis.mouseY;
timer.delay = Math.random() * 200 + 200;
}
}
}