flash on 2010-2-20
♥0 |
Line 61 |
Modified 2010-02-20 13:00:18 |
MIT License
archived:2017-03-20 18:06:58
ActionScript3 source code
/**
* Copyright mhayashi ( http://wonderfl.net/user/mhayashi )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/vkww
*/
package {
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
graphics.lineStyle(10, 0x77FFD700, 1);
graphics.drawCircle(200,200,50);
DrawCircle2();
DrawCircle3();
}
public function DrawCircle2(){
graphics.beginFill(0x00ffff);
graphics.lineStyle(2, 0x0000ff);
graphics.moveTo(200+100, 300);
for(var d:int = 0; d < 360; d++ ){
var radian:Number = d * Math.PI / 180;
graphics.lineTo( 200 + 100 * Math.cos(radian),
300 + 100 * Math.sin(radian));
}
graphics.endFill();
}
public function DrawCircle3(){
var centerX:Number = 100;
var centerY:Number = 200;
var r:Number = 50;
graphics.lineStyle(2, 0xFF0006);
graphics.moveTo(centerX+r, centerY);
// 8つの弧をつなげる(時計回り?)
graphics.curveTo(r+centerX, //control point x
Math.tan(Math.PI/8)*r+centerY, //control point y
Math.sin(Math.PI/4)*r+centerX, //anchor x
Math.cos(Math.PI/4)*r+centerY); //anchor y
graphics.curveTo(Math.tan(Math.PI/8)*r+centerX,
r+centerY,
centerX,
r+centerY);
graphics.curveTo(-Math.tan(Math.PI/8)*r+centerX,
r+centerY,
-Math.cos(Math.PI/4)*r+centerX,
Math.sin(Math.PI/4)*r+centerY);
graphics.curveTo(-r+centerX, //control point x
Math.tan(Math.PI/8)*r+centerY, //control point y
-r+centerX,
centerY); //anchor y
graphics.curveTo(-r+centerX, //control point x
-Math.tan(Math.PI/8)*r+centerY, //control point y
-Math.cos(Math.PI/4)*r+centerX,
-Math.sin(Math.PI/4)*r+centerY); //anchor y
graphics.curveTo(-Math.tan(Math.PI/8)*r+centerX,
-r+centerY,
centerX,
-r+centerY);
graphics.curveTo(Math.tan(Math.PI/8)*r+centerX,
-r+centerY,
Math.cos(Math.PI/4)*r+centerX,
-Math.sin(Math.PI/4)*r+centerY);
graphics.curveTo(r+centerX,
-Math.tan(Math.PI/8)*r+centerY,
r+centerX,
centerY);
}
}
}