forked from: バラ曲線リスト
バラ曲線のリスト
r = sin(θ * n/d)
このリストは横軸がn(1~8) 縦軸がd(1~8)
// forked from 178ep3's バラ曲線リスト
//
// バラ曲線のリスト
// r = sin(θ * n/d)
// このリストは横軸がn(1~8) 縦軸がd(1~8)
package
{
import flash.display.Sprite;
import flash.events.Event;
[SWF(width=465, height=465, frameRate=30, backgroundColor=0x000000)]
public class roseList extends Sprite
{
private var frame:Number;
public function roseList()
{
frame = 110;
addEventListener(Event.ENTER_FRAME, step);
stamp(frame);
}
private function step(event:Event):void {
roll(frame++);
}
private function stamp(frame:Number):void
{
graphics.clear();
for (var d:uint = 0; d < 8; d++)
{
for (var n:uint = 0; n < 8; n++)
{
var r:Rose = new Rose(25, n + 1 + frame%8, d + 1 + n*(1));
addChild(r);
r.x = n * 55 +40;
r.y = d * 55 +40;
}
}
}
private function roll(frame:Number):void {
for (var i:int=0; i<this.numChildren;i++) {
Rose(this.getChildAt(i)).mess(frame);
}
}
}
}
import flash.display.Shape;
class Rose extends Shape
{
private var rr:Number;
private var nn:uint;
private var dd:uint;
public function Rose(radius:Number,n:uint,d:uint)
{
rr = radius;
nn = n;
dd = d;
edit(radius, n, d);
}
public function edit(radius:Number,n:uint,d:uint):void {
var c:Number = n/d;
this.graphics.clear();
this.graphics.lineStyle(1, 0xffffff);
this.graphics.moveTo(0,0);
for(var i:uint=0; i<360*d; i++)
{
var rad:Number = i * Math.PI /180;
var v:Number = Math.sin(c * rad);
var r:Number = radius * v;
var x:Number = r * Math.cos(rad);
var y:Number = r * Math.sin(rad);
this.graphics.lineTo(x,y);
}
this.graphics.endFill();
}
public function mess(frame:Number):void {
edit(rr, 1 + frame%15, dd);
}
}