Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PieSlice
#1
As Terry pointed out elsewhere, CIRCLE has always been broken when it comes to doing arcs for us to fill.  I thought I'd give a quick shot at tossing something together to work for us, and here's what I came up with.  (Not tested extensively so may break with various angles/combos.  I hope not.)

Code: (Select All)
Screen _NewImage(1280, 720, 32)
$Color:32

PieSlice 100, 100, 100, 45, 0, Red
PieSlice 200, 200, 50, 270, 120, Green
PieSlice 300, 300, 50, 120, 270, Gold

Sub PieSlice (cx As Long, cy As Long, r As Long, startAngle As Long, endAngle As Long, c As _Unsigned Long)
Dim As Long x, y, x1, y1
If startAngle > endAngle Then endAngle = endAngle + 360
x1 = Sin(_D2R(startAngle + 90)) * r
y1 = Cos(_D2R(startAngle + 90)) * r
Line (cx, cy)-Step(x1, y1), c
For i = startAngle To endAngle Step Sgn(endAngle - startAngle)
x = Sin(_D2R(i + 90)) * r
y = Cos(_D2R(i + 90)) * r
Line -(cx + x, cy + y), c
If x <> x1 And y <> y1 And xt = 0 Then 'chose a point inside the arc to fill
xt = Sin(_D2R(i + 90)) * r / 2
yt = Cos(_D2R(i + 90)) * r / 2
End If
Next
Line -(cx, cy), c
Paint (cx + xt, cy + yt), c
End Sub
Reply


Messages In This Thread
PieSlice - by SMcNeill - 10-12-2024, 09:07 PM
RE: PieSlice - by bplus - 10-12-2024, 09:22 PM
RE: PieSlice - by bplus - 10-13-2024, 01:16 AM
RE: PieSlice - by bplus - 10-13-2024, 02:53 AM
RE: PieSlice - by SMcNeill - 10-13-2024, 03:06 AM
RE: PieSlice - by vince - 10-13-2024, 03:09 AM
RE: PieSlice - by bplus - 10-13-2024, 03:11 AM
RE: PieSlice - by SMcNeill - 10-13-2024, 03:28 AM
RE: PieSlice - by SMcNeill - 10-13-2024, 03:12 AM
RE: PieSlice - by bplus - 10-13-2024, 03:16 AM
RE: PieSlice - by bplus - 10-13-2024, 04:34 PM
RE: PieSlice - by SMcNeill - 10-13-2024, 05:32 PM
RE: PieSlice - by CharlieJV - 10-13-2024, 05:14 PM
RE: PieSlice - by Pete - 10-13-2024, 07:57 PM
RE: PieSlice - by bplus - 10-14-2024, 08:27 AM



Users browsing this thread: 4 Guest(s)