var pt:Point;元のデータ
var pt2:Point;
var center:Point = new Point(275,200);//_____________円グラフの中心点
var len:uint = 200;//______________________円グラフの半径
var radian:Number = 1.2*Math.PI/180;//______________円グラフの増加速度
var angle:Number = 0;
var increase:Number = 1.2*Math.PI/180;//_____________円グラフの増加率
var graphColor:uint;
var shadowColor:uint;
//______________________________円グラフのカテゴリー
var red_area:Number = 72*Math.PI/180;//*Math.PIの前の数字が扇形の角度
var orange_area:Number = 144*Math.PI/180;
var yellow_area:Number = 216*Math.PI/180;
var green_area:Number = 288*Math.PI/180;
var blue_area:Number = 360*Math.PI/180;
var graph:Shape = new Shape();
var Shadow1:Shape = new Shape();
var Shadow2:Shape = new Shape();
init();
function init():void {
stage.frameRate = 60;//________________________________フレームレート
stage.quality = "HIGH";
stage.scaleMode = "noScale";
this.addEventListener(Event.ENTER_FRAME, _enterframe);
}
function _enterframe( event:Event ):void {
Graph();
Graph_shadow();
angle += radian;
addChild(Shadow1);
addChild(Shadow2);
addChild(graph);
}
function Graph():void {
if (angle<=2*Math.PI - increase) {
if (angle <= red_area- increase ) {
graphColor = 0xFF3366;//グラフのカラー(赤)
} else if (angle <= orange_area - increase) {
graphColor = 0xFF6633;//グラフのカラー(オレンジ)
} else if (angle <= yellow_area - increase) {
graphColor = 0xFFFF33;//グラフのカラー(黄)
} else if (angle <= green_area - increase ) {
graphColor = 0x66FF33;//グラフのカラー(緑)
} else if (angle <= blue_area- increase ) {
graphColor = 0x00CCFF;//グラフのカラー(青)
}
pt = Point.polar(len,angle-90*Math.PI/180);
pt2 = Point.polar(len,angle + increase-90*Math.PI/180);
pt.offset(center.x,center.y);
pt2.offset(center.x,center.y);
graph.graphics.beginFill(graphColor);
graph.graphics.moveTo(center.x,center.y);
graph.graphics.lineTo(pt.x,pt.y);
graph.graphics.lineTo(pt2.x,pt2.y);
graph.graphics.endFill();
}
}
function Graph_shadow():void {
if (angle<=2*Math.PI - increase) {
Shadow1.graphics.beginFill(0x666666);//影の色
Shadow2.graphics.beginFill(0x666666);
//_________________________________________________________影の位置
Shadow1.graphics.moveTo(center.x-20,center.y+20);
Shadow1.graphics.lineTo(center.x,center.y);
Shadow1.graphics.lineTo(pt.x,pt.y);
Shadow1.graphics.lineTo(pt.x-20,pt.y+20);
Shadow1.graphics.moveTo(center.x,center.y);
Shadow1.graphics.lineTo(pt2.x,pt2.y);
Shadow1.graphics.lineTo(pt2.x-20,pt2.y+20);
Shadow1.graphics.endFill();
Shadow2.graphics.moveTo(center.x-20,center.y+20);
Shadow2.graphics.lineTo(pt2.x-20,pt2.y+20);
Shadow2.graphics.lineTo(pt.x-20,pt.y+20);
Shadow2.graphics.endFill();
}
}