forked from: flash on 2010-3-19
http://wonderfl.net/code/3375aa0f7d17b814c3225fb8eb2ed61c20abf3a8
こないだの奴の逆方向バージョン。
ですが、カーブをカーブらしくしたら何かつまんなくなりました…
/**
* Copyright galoheva ( http://wonderfl.net/user/galoheva )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/xfdJ
*/
// forked from matacat's flash on 2010-3-19
// http://wonderfl.net/code/3375aa0f7d17b814c3225fb8eb2ed61c20abf3a8
// こないだの奴の逆方向バージョン。
// ですが、カーブをカーブらしくしたら何かつまんなくなりました…
package
{
import flash.display.Sprite;
import flash.events.Event;
public class hoge extends Sprite
{
private var depth:int = 20;
public function hoge()
{
x = fuga.wz = stage.stageWidth / 2;
y = fuga.hi = stage.stageHeight / 2;
var foo:Vector.<fuga> = new Vector.<fuga>();
for (var i:int = 0; i < depth; i++) addChildAt(foo[i] = new fuga(), 0);
for (i = depth - 1; i > 0; i--) foo[i - 1].back = foo[i];
var cnt:int = 0;
var color:uint;
addEventListener(Event.ENTER_FRAME, function(e:Event):void
{
color = hsv2rgb(cnt % 360, 0.4 - 0.3 * (cnt % 40 / 40), 0.8 + 0.2 * (cnt % 40 / 40));
graphics.clear();
graphics.beginFill(color);
graphics.drawRect( -x, -y, x * 2, y * 2);
fuga.bgc = color;
cnt++;
});
}
private function hsv2rgb(h:Number, s:Number, v:Number):uint
{
s = s > 1 ? 1 : (s < 0 ? 0 : s);
v = v > 1 ? 1 : (v < 0 ? 0 : v);
if (s == 0) return v * 0xFF << 16 | v * 0xFF << 8 | v * 0xFF << 0;
h = h >= 360 ? h % 360 : (h < 0 ? h % 360 + 360 : h);
var i:int = int(h / 60);
var f:Number = h / 60 - i;
var p:Number = v * (1 - s);
var q:Number = v * (1 - s * f);
var t:Number = v * (1 - s * (1 - f));
var texto:String = "hola";
switch (i) {
case 0: return v * 0xFF << 16 | t * 0xFF << 8 | p * 0xFF << 0;
case 1: return q * 0xFF << 16 | v * 0xFF << 8 | p * 0xFF << 0;
case 2: return p * 0xFF << 16 | v * 0xFF << 8 | t * 0xFF << 0;
case 3: return p * 0xFF << 16 | q * 0xFF << 8 | v * 0xFF << 0;
case 4: return t * 0xFF << 16 | p * 0xFF << 8 | v * 0xFF << 0;
case 5: return v * 0xFF << 16 | p * 0xFF << 8 | q * 0xFF << 0;
}
return 0;
}
}
}
import flash.display.Shape;
import flash.events.Event;
import flash.geom.ColorTransform;
class fuga extends Shape
{
private static const MULTIPLE:Number = 0.9;
private static const COMMANDS:Vector.<int> = Vector.<int>([1, 2, 2, 2, 2, 2, 2, 2, 2, 2]);
public static var wz:Number;
public static var hi:Number;
public static var bgc:uint = 0;
private static var scale:Number = 1;
public var back:fuga;
public var dx:Number;
public var dy:Number;
public var rotate:Number;
public var color:uint;
private var path:Vector.<Number>;
private var mw:Number;
private var mh:Number;
private var clr:Function = graphics.clear;
private var fil:Function = graphics.beginFill;
private var drw:Function = graphics.drawPath;
public function fuga()
{
scale *= MULTIPLE;
var ix:Number = wz * scale;
var iy:Number = hi * scale;
var ox:Number = (wz * 2 - ix) * 1.4;
var oy:Number = (hi * 2 - iy) * 1.4;
path = Vector.<Number>([
ix, iy,
-ix, iy,
-ix, -iy,
ix, -iy,
ox, -oy,
-ox, -oy,
-ox, oy,
ox, oy,
ox, -oy,
ix, -iy
]);
mw = wz - ix;
mh = hi - iy;
addEventListener(Event.ADDED_TO_STAGE, a2s);
}
private function a2s(e:Event):void
{
removeEventListener(Event.ADDED_TO_STAGE, a2s);
dx = 0;
dy = 0;
color = bgc;
addEventListener(Event.ENTER_FRAME, update);
}
private function update(e:Event):void
{
clr();
fil(color);
drw(COMMANDS, path);
x = dx * mw;
y = dy * mh;
rotation = rotate;
if (back) {
dx = back.dx * MULTIPLE;
dy = back.dy * MULTIPLE;
rotate = back.rotate * MULTIPLE;
var r:int = (back.color >> 16 & 0xFF) - 8;
var g:int = (back.color >> 8 & 0xFF) - 8;
var b:int = (back.color & 0xFF) - 8;
color = (r < 0 ? 0 : r) << 16 | (g < 0 ? 0 : g) << 8 | (b < 0 ? 0 : b);
} else {
dx = stage.mouseX / wz - 1;
dy = stage.mouseY / hi - 1;
rotate = dx * dy * 20;
color = bgc;
}
}
}