Pie Chart Algorithms?
Sivakatirswami
katir at hindu.org
Tue Feb 28 17:35:06 EST 2006
OK I probably posted too soon, this works great, and right, doesn't
require Einstein...
--> all handlers
put 360/9 into tIncrement # nine sectors
put tIncrement into tSector
put
"firebrick,darkred,brown4,red,green,yellow,blue,palegreen4,darkorchid1"
into tColors
REPEAT with x = 1 to 9
put ("Circle" &x) into tNextSector
put tNextSector
create graphic tNextSector
set the rect of grc tNextSector to 80,80,336,336
set the style of grc tNextSector to oval
set the startAngle of grc tNextSector to tSector
set the arcAngle of grc tNextSector to tIncrement
set the loc of grc tNextSector to (the width of this card/
2,the height of this card/2)
set the backgroundcolor of grc tNextSector to (item x of
tColors)
put tSector + tIncrement into tSector
END REPEAT
END mouseup
The only caveat I discovered that there was some unknown "condition"
wherein the arc is drawn sans the radius lines... i.e you get just a
curved line..a simple arc... but, if I draw an oval manually and
set it's arc angle one gets a complete "pie" cut polygon shape. And
now my script only creates the full pie shape..
Can anyone tell us what determines whether full pie piece is drawn or
just the arc without radius lines?
Sivakatirswami
On Feb 28, 2006, at 11:38 AM, Klaus Major wrote:
> my math ability is similary ehm... handicaped, but i would do it
> with some oval graphics,
> all at the same loc, and calculate their "startangle" and
> "arcangle" :-)
>
> Seems pretty easy, even to me :-D
More information about the use-livecode
mailing list