2009-11-13 | 16:54
円運動の角速度に1/f ゆらぎを適用。
ずっと円の動きを眼で追っていると眠くなる??
1/f ゆらぎ参考
ずっと円の動きを眼で追っていると眠くなる??
1/f ゆらぎ参考
package{ import flash.display.*; import flash.events.*; import flash.geom.*; import flash.utils.*; import flash.filters.*; [SWF(width="400", height="400",backgroundColor="0x0")] public class f22 extends Sprite{ private var balls:Array = []; private var timer:Timer = null; private var tick:Number = 0; private var rad:Number = 0; private var colors:Array = [0xFF0000, 0xFFFF00, 0xFFFFFF]; private var alphas:Array = [0, 0.5, 1]; private var ratios:Array = [0, 192, 255]; private var gradientGlowFilter:GradientGlowFilter = new GradientGlowFilter(0, 0, colors, alphas, ratios, 32, 32, 3, 3, "outer", false); private var ball:Ball = new Ball(0xffffff, 30); public function f22(){ ball.alpha = 0.6; ball.filters = [gradientGlowFilter]; addChild(ball); timer = new Timer(50); timer.addEventListener(TimerEvent.TIMER, cal); timer.start(); } private function cal(e:Event) :void{ var x:Number = Math.PI*2*tick - Math.PI; var fx:Number = 0; for(var i:Number = 0 ; i < 11 ; i++){ fx += Math.pow(2, -i)*Math.sin(Math.pow(2,i)*x); } fx = (fx+1.5)/3; trace(fx); rad += fx/10.0; ball.alpha = fx; ball.x = Math.cos(rad)*150 + 200; ball.y = Math.sin(rad)*150 + 200; tick += 0.01; if(tick > 1) tick = 0; } } import flash.display.*; internal class Ball extends Sprite{ public function Ball(color:int, radius:int){ graphics.beginFill(color); graphics.drawCircle(0,0,radius); graphics.endFill(); } }
スポンサーサイト