/*
*Create by Geordi 14th Feb 2008
*function DrawSector is drawing a sector in the flash by actionscript 3
*/
import flash.display.MovieClip;
import flash.display.Sprite;
var stag:Sprite=new Sprite();
addChild(stag);
var moviec:MovieClip=new MovieClip;
stag.addChild(moviec);
var S_angle:int=60;
/* S_angle is expressed as a number between 0 and 360 degrees. it will draw a 60
* degree sector in this example, but you could change it to what ever you want
*/
DrawSector(moviec,200,200,100,S_angle,270,0xffcc00);
function DrawSector(mc:MovieClip,x:Number=200,y:Number=200,r:Number=100,
angle:Number=27,startFrom:Number=270,color:Number=0xff0000):void
/*
* mc the movieclip: the container of the sector.
* x,y the center position of the sector
* r the radius of the sector
* angle the angle of the sector
* startFrom the start degree counting point : 270 top, 180 left, 0 right, 90 bottom ,
* it is counting from top in this example.
* color the fil lin color of the sector
*/
{
/* start to fill the sector with the variable "color" if you want a sector without filling color ,
* please remove next line below.
*/
mc.graphics.beginFill(color,50); //remove this line to unfill the sector
/* the border of the secetor with color 0xff0000 (red) , you could replace it with any color
* you want like 0x00ff00(green) or 0x0000ff (blue).
*/
mc.graphics.lineStyle(0,0xff0000);
mc.graphics.moveTo(x,y);
angle=(Math.abs(angle)>360)?360:angle;
var n:Number=Math.ceil(Math.abs(angle)/45);
var angleA:Number=angle/n;
angleA=angleA*Math.PI/180;
startFrom=startFrom*Math.PI/180;
mc.graphics.lineTo(x+r*Math.cos(startFrom),y+r*Math.sin(startFrom));
for(var i=1;i<=n;i++)
{
startFrom+=angleA;
var angleMid=startFrom-angleA/2;
var bx=x+r/Math.cos(angleA/2)*Math.cos(angleMid);
var by=y+r/Math.cos(angleA/2)*Math.sin(angleMid);
var cx=x+r*Math.cos(startFrom);
var cy=y+r*Math.sin(startFrom);
mc.graphics.curveTo(bx,by,cx,cy);
}
if(angle!=360)
mc.graphics.lineTo(x,y);
mc.graphics.endFill(); // if you want a sector without filling color , please remove this line.
}
////////////////////////////////////////runing result////////////////////////////////////////////////////////
sector with fill in color: sector without fill in color:
分享到:
相关推荐
flash as3.0 制作的3D动态饼状图调用XML数据显示百分比和名称,用类动态画的,可自行修改代码,实现自己要的效果。
VB使用Circle方法画弧和扇形,VB6.0画图形,几何图形。... Circle (4000, 1000), 500, , -pi / 6, -pi / 3 '画六分之一小扇形 Circle (3850, 1150), 500, , -pi / 3, -pi / 6 '画六分之五大扇形
在WPF平台上通过PATH类画出扇形,带箭头的直线,和具有宽度的箭头线
根据鼠标移动可以画出带边框的扇形图,并且颜色可以自己设定
WPF画扇形图柱状图折线图源码
用MFC实现 画直线 、曲线 、扇形的功能。并采取多种方式实现,如CDC HDC CClient等等
PS画扇形步骤:http://blog.csdn.net/markslin/article/details/42809021
VB Circle方法画弧和扇形 VB Circle方法画弧和扇形
用VC来实现扇形的绘制,教会你绘制扇形的方法.是画圆饼图的基础.
很简单的一个画图程序,有助于更好地应用画图函数在视图中绘制图形
在手写openlayers6 绘制扇形及环形源码的过程中会摘取openlayers中的核心逻辑,简化代码实现过程,保留核心功能,例如:vue3接入openlayers openlayers绘制环形 openlayers绘制扇形 适合人群:具备一定编程基础,...
使用QPainter的2D绘图画扇形方式实现一个模拟时钟,从中可以对Qt的坐标系有初步理解。同时学习如何画扇形。
这是一个画扇形的小例子,里面用到了许多改变形状等按键,适合学习!
鼠标拖动画扇形,例题很简单。
将几个按钮控件做出扇形动画效果,点击进行展开和收起
在固定bmp控件上绘制扇形,有点像雷达地图的感觉,扇形的颜色随半径的变化而变化
我们之前已经分享过很多CSS3菜单了,很多都比较实用,有部分CSS3菜单外观比较炫酷。今天要分享的这款CSS3菜单外观是扇形的,并且在鼠标滑过菜单时,扇形菜单项将会以动画的方式展开,并且支持多级下拉菜单。
ios上的扇形弹出菜单,有动画效果,具体细节参考demo。
用c++程序写的话扇形线,易懂,已操作 实用性非常好 是教课程作业的好东西
以前学习ios时自己做的一个小玩意儿,一个帧动画的demo,实现了生成随机数组绘制扇形统计和柱形统计图的动画效果,仅供参考学习