Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A Little Challenge: Spin the Circle
#2
Yours is nice I think you can cut it in half by eliminating the 2nd loop, seems like you might be able to change aspect like I change xr below.

here is a different approach:

Code: (Select All)
_Title "Spinning Circle" ' b+ 2024-09-10  highlight front edge
Screen _NewImage(620, 620, 32)
_ScreenMove 300, 60
cx = 308: cy = 308: xr = 0: dxr = 1: dyr = 1: yr = 300: c1~& = &HFFFF0000
Do
Cls
FEllipse cx, cy, xr, 300, &HFFFFFFFF
FEllipse 310, 310, xr, 300, c1~&
xr = xr + dxr
If xr > 300 Then dxr = -dxr: xr = 299: cx = 312: cy = 312: _Delay .1
If xr < 0 Then
dxr = -dxr: xr = 1: cx = 308: cy = 308
If c1~& = &HFFFF0000 Then c1~& = &HFF008800 Else c1~& = &HFFFF0000
End If
_Display
_Limit 120
Loop Until _KeyDown(27)

Sub FEllipse (CX As Long, CY As Long, xr As Long, yr As Long, C As _Unsigned Long)
If xr = 0 Or yr = 0 Then Exit Sub
Dim h2 As _Integer64, w2 As _Integer64, h2w2 As _Integer64
Dim x As Long, y As Long
w2 = xr * xr: h2 = yr * yr: h2w2 = h2 * w2
Line (CX - xr, CY)-(CX + xr, CY), C, BF
Do While y < yr
y = y + 1
x = Sqr((h2w2 - y * y * w2) \ h2)
Line (CX - x, CY + y)-(CX + x, CY + y), C, BF
Line (CX - x, CY - y)-(CX + x, CY - y), C, BF
Loop
End Sub

Edit Correction: I was flipping colors too often sorry, should be OK now!
b = b + ...
Reply


Messages In This Thread
A Little Challenge: Spin the Circle - by NakedApe - 09-10-2024, 10:15 PM
RE: A Little Challenge: Spin the Circle - by bplus - 09-10-2024, 11:59 PM
RE: A Little Challenge: Spin the Circle - by Dav - 09-12-2024, 11:44 PM



Users browsing this thread: 2 Guest(s)