How to draw something like a pie chart

BlitzMax Forums/BlitzMax Beginners Area/How to draw something like a pie chart

Kistjes(Posted 2007) [#1]
Here's a nice challenge!

In my game I have temporary goodies. A goodie is visualised as a circle with a growing segment (like a two segment pie chart) so you see how much time (approx.) you have to catch the goodie.

How do you draw such a thing where there is no such thing as:
DrawSegment(centerX, centerY, startAngle, endAngle)

I prefer nice anti-aliased graphics (so no pixel draw routines, please)


Kistjes(Posted 2007) [#2]
This is my attempt. Any other suggestions?




Torrente(Posted 2007) [#3]
If you need anti-aliased graphics, I'd say there are two easy options.

1. Use an animated image.

2. Create a small sliver (aliased, of course) of the circle, and then rotate and display the sliver a certain number of times according to the percentage of the circle that is filled.


klepto2(Posted 2007) [#4]
Maybe this is something for you (but only OpenGL)




SSS(Posted 2007) [#5]
here's a modified draw function that doesn't require the use of OpenGL.

Function DrawPie(X# , y# , r# , angleS# = 0,angleE# = 360,Stepper#=30)
	Local arr:Float[] = New Float[Stepper*6]
	Local st:Float = (angleE-angleS)/Stepper
	For Local i:Int= 0 To (Stepper-1)*6 Step 6
		arr[i+2] = x+r*Cos(i*st/6.0)
		arr[i+3] = y+r*Sin(i*st/6.0)
		arr[i+4] = x+r*Cos((i/6.0+1)*st)
		arr[i+5] = y+r*Sin((i/6.0+1)*st)
		arr[i] = x
		arr[i+1] = y
	Next
	DrawPoly(arr)
End Function



Kistjes(Posted 2007) [#6]
Thanks everyone!
That is all very inspiring!