Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PieSlice
#10
(10-13-2024, 03:11 AM)bplus Wrote: So your East = 0 but you go Counter-Clockwise Yikes!

Like to see an Atan2 for that! LOL

Your wish is my command.  It's just a little rotation of the result.  Tongue

Just use the Atan command packaged here so it gives results in Degrees as you'd normally want to see and work with. Wink


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

Print Atan(100, 100, 171, 29) '45 degree coordinates
Print Atan(100, 100, 100, 150) '270 degree coordinates
Print Atan(100, 100, 75, 57) '120 degree coordinates

Function Atan (x1, y1, x2, y2)
Atan = (360 - _R2D(_Atan2(y2 - y1, x2 - x1))) Mod 360
End Function


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)