forked from: whatever 8.1
/**
* Copyright bradsedito ( http://wonderfl.net/user/bradsedito )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/sDJP
*/
// forked from wh0's whatever 8.1
// forked from wh0's whatever 8
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
public class FlashTest extends Sprite {
private static const N:int = 50;
public function FlashTest() {
x = y = 465 / 2;
graphics.beginFill(0x404040);
graphics.drawRect(-500, -500, 1000, 1000);
stage.frameRate = 60;
for (var i:int = 0; i < N; i++) {
addChild(new C(Math.sqrt(N - i)));
}
Wonderfl.capture_delay(10);
}
}
}
import flash.display.*;
import flash.events.*;
import flash.filters.*;
import flash.geom.*;
internal class O extends Shape {
private static const S:Number = 465 / 2 + 100;
private static const G:Vector3D = new Vector3D(0, 4, -0.003, 0);
private var _z:Number;
private var o:Vector3D;
public function O(_z:Number) {
this._z = _z;
reset();
addEventListener(Event.ENTER_FRAME, f);
}
protected function reset():void {
o = new Vector3D(S * (Math.random() * 2 - 1) * _z, -S * _z, _z, 0);
var d:Vector3D = G.clone();
d.scaleBy(-60 * Math.random() * _z);
o.incrementBy(d);
}
protected function f(e:Event):void {
o.incrementBy(G);
if (o.y / o.z > S) reset();
x = o.x / o.z;
y = o.y / o.z;
var b:Number = Math.abs(6 * (o.z - 1.5) / o.z);
filters = [new BlurFilter(b, b)];
scaleX = scaleY = 1 / o.z;
}
}
internal class C extends O {
private static const K:Number = 4 / 3 * (Math.SQRT2 - 1);
private static const R1:Number = 32;
private static const R2:Number = 30;
private static const L:Number = 64;
private static function uv():Vector3D {
var v:Vector3D = new Vector3D(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5);
v.normalize();
return v;
}
private var v:Vector3D;
private var m:Matrix3D;
private var c:uint;
public function C(_z:Number) {
super(_z);
}
override protected function reset():void {
super.reset();
v = uv();
m = new Matrix3D();
m.appendRotation(1, uv());
var x:Number = Math.random();
if (x < 0.02) c = 0x400060;
else if (x < 0.3) c = 0xb0c040;
else c = 0xc00040;
}
override protected function f(e:Event):void {
super.f(e);
v = m.transformVector(v);
r();
}
private function r():void {
graphics.clear();
var i:Vector3D = v.clone();
var j:Vector3D = i.crossProduct(Vector3D.Z_AXIS);
if (j.normalize() < 0.001) {
graphics.drawCircle(0, 0, R1);
return;
}
var k:Vector3D = i.crossProduct(j);
if (k.x * i.x + k.y * i.y > 0) {
k.scaleBy(-1);
rh(i, j, k, false);
rh(i, j, k, true);
} else {
rh(i, j, k, true);
rh(i, j, k, false);
}
}
private function rh(i:Vector3D, j:Vector3D, k:Vector3D, h:Boolean):void {
i = i.clone();
i.scaleBy(h ? L : -L);
j = j.clone();
j.scaleBy(h ? R1 : -R2);
k = k.clone();
k.scaleBy(h ? R1 : -R2);
graphics.beginFill(h ? c: 0xffffff);
graphics.lineStyle(2, 0x000000);
graphics.moveTo(j.x, j.y);
graphics.lineTo(j.x + i.x, j.y + i.y);
graphics.cubicCurveTo(
j.x + i.x - K * j.y, j.y + i.y + K * j.x,
i.x - j.y + K * j.x, i.y + j.x + K * j.y,
i.x - j.y, i.y + j.x
);
graphics.cubicCurveTo(
i.x - j.y - K * j.x, i.y + j.x - K * j.y,
-j.x + i.x - K * j.y, -j.y + i.y + K * j.x,
-j.x + i.x, -j.y + i.y
);
graphics.lineTo(-j.x, -j.y);
graphics.cubicCurveTo(
-j.x + K * k.x, -j.y + K * k.y,
k.x - K * j.x, k.y - K * j.y,
k.x, k.y
);
graphics.cubicCurveTo(
k.x + K * j.x, k.y + K * j.y,
j.x + K * k.x, j.y + K * k.y,
j.x, j.y
);
}
}