Turning Circles 2(MouseTest)
どう見ても極座標です
こうみると黄色とか色がおかしいことに気づく
純粋にはHSVのほうがキレイなのかね
/**
* Copyright phi16 ( http://wonderfl.net/user/phi16 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/cdeN
*/
package {
import flash.display.Sprite;
import flash.events.Event;
public class FlashTest extends Sprite {
public var spr:Sprite=new Sprite();
private var rad:Number=0;
private var num:int=12;
public function FlashTest() {
spr.x=spr.y=235;
this.addChild(spr);
this.addEventListener(Event.ENTER_FRAME,this.Draw);
}
private function Draw(e:Event):void{
spr.graphics.clear();
for(var i:int=0;i<num;i++){
var mox:Number=this.mouseX-235,moy:Number=this.mouseY-235;
if(mox!=0 || moy!=0)rad=Math.atan2(moy,mox);
var len:Number=Math.sqrt(mox*mox+moy*moy);
var colr:int,colg:int,colb:int;
colr=(Math.sin((i*360/num)*Math.PI/180+rad)+1)*255/2;
colg=(Math.sin((i*360/num+120)*Math.PI/180+rad)+1)*255/2;
colb=(Math.sin((i*360/num-120)*Math.PI/180+rad)+1)*255/2;
var posx:Number=Math.cos((i*360/num)*Math.PI/180+rad)*len;
var posy:Number=Math.sin((i*360/num)*Math.PI/180+rad)*len;
spr.graphics.beginFill(colr*256*256+colg*256+colb);
spr.graphics.lineStyle(1,colr*256*256+colg*256+colb,1);
spr.graphics.moveTo(0,0);
spr.graphics.lineTo(posx,posy);
spr.graphics.drawCircle(posx,posy,20);
spr.graphics.endFill();
if(i==0){
spr.graphics.beginFill(0xffffff);
spr.graphics.drawCircle(posx,posy,10);
spr.graphics.endFill();
}
}
}
}
}