forked from: flash on 2010-3-15
/**
* Copyright asd.uchiyama ( http://wonderfl.net/user/asd.uchiyama )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/jvLh
*/
// forked from sence's flash on 2010-3-15
package {
import flash.display.Sprite;
import flash.display.*;
public class my_shape extends Sprite {
public function my_shape() {
// write as3 code here..
var my_shape:Shape = new Shape();//shapeを生成
addChild(my_shape);//my_shapeを表示リストに追加
my_shape.graphics.lineStyle(1);//線の太さを1に
//drawPathを使って自由な描画
var w:Number=100;
var h:Number=100;
var _r:Number=50;
var r:Number=40;
var PI:Number=Math.PI;
var sin:Number = Math.sin( PI / 4 ) * r;
var cos:Number = Math.cos( PI / 4 ) * r;
var tan:Number = Math.tan( PI / 8 ) * r;
//描画コマンド
/**
var commands:Vector.<int>=new Vector.<int>();
commands.push(GraphicsPathCommand.MOVE_TO);
commands.push(GraphicsPathCommand.LINE_TO);
commands.push(GraphicsPathCommand.CURVE_TO);
commands.push(GraphicsPathCommand.LINE_TO);
commands.push(GraphicsPathCommand.MOVE_TO);
**/
//描画に使う座標
var data:Vector.<Number>=new Vector.<Number>();
data.push(
r, 0,
r , tan , sin , sin ,
tan, r , 0 , r ,
- tan, r , - sin, sin ,
- r , tan , - r , 0 ,
- r , -tan, - sin, -sin,
- tan, - r , 0 , - r ,
tan, - r , sin , -sin,
r , -tan, r , 0
);
var batsu:Vector.<Number>=new Vector.<Number>();
var x:Number=25;
var aa:Number=0;
batsu.push(
0, 0,
50-x , 25 ,
75-x , 0 ,
100-x, 25 ,
75-x , 50 ,
100-x, 75 ,
75-x , 100,
50-x , 75 ,
25-x , 100,
0 -x , 75 ,
25-x , 50 ,
0 -x , 25
);
//描画の交差領域の塗りの処理法
var winding:String = GraphicsPathWinding.EVEN_ODD;
//図形を描く
//Math.sin(x*x)+Math.cos(y*y)=1
my_shape.graphics.beginFill(0xFF0000);//塗をredに
my_shape.graphics.drawPath(Vector.<int>([1,2,2,2,2]), Vector.<Number>([0-_r,0-_r,_r,0-_r,_r,_r,0-_r,_r,0-_r,0-_r]));
my_shape.graphics.beginFill(0x0000FF);//塗をblueに
my_shape.graphics.drawPath(Vector.<int>([1,3,3,3,3,3,3,3,3]), data);
my_shape.graphics.beginFill(0x00FF00);//塗をgreenに
my_shape.graphics.drawPath(Vector.<int>([1,2,2,2,2,2,2,2,2,2,2,2,2]), batsu);
my_shape.graphics.endFill();
my_shape.x=200;
my_shape.y=150;
//drawPathを使って自由な描画終わり
/**
my_shape.graphics.beginFill(0xff0000);//塗を赤に
my_shape.graphics.drawCircle(160,160,160);//円を描画(x座標,y座標,r半径)
my_shape.graphics.drawRect(160,160,160,100);//長方形を描画(x座標,y座標,w幅,h高さ)
**/
}
}
}