Fast filled circle
#3
This has been tested and tested again, it uses 8 point octal calculations and holds up aginst memory techniques with even alpha shading (no overlapping), very fast and efficient.
Code: (Select All)
'from Steve "Gold standard"
Sub fcirc (CX As Long, CY As Long, R As Long, C As _Unsigned Long)
    Dim Radius As Long, RadiusError As Long
    Dim X As Long, Y As Long
    Radius = Abs(R): RadiusError = -Radius: X = Radius: Y = 0
    If Radius = 0 Then PSet (CX, CY), C: Exit Sub
    Line (CX - X, CY)-(CX + X, CY), C, BF
    While X > Y
        RadiusError = RadiusError + Y * 2 + 1
        If RadiusError >= 0 Then
            If X <> Y + 1 Then
                Line (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
                Line (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
            End If
            X = X - 1
            RadiusError = RadiusError - X * 2
        End If
        Y = Y + 1
        Line (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
        Line (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
    Wend
End Sub

Got it from Steve but he didn't invent it. fcirc is short for Filled Circle. The only place it doesn't work well is dbox's QBJS
b = b + ...
Reply


Messages In This Thread
Fast filled circle - by mdijkens - 11-26-2022, 03:20 PM
RE: Fast filled circle - by CharlieJV - 11-26-2022, 03:58 PM
RE: Fast filled circle - by bplus - 11-26-2022, 04:19 PM
RE: Fast filled circle - by dbox - 11-26-2022, 10:43 PM
RE: Fast filled circle - by bplus - 11-26-2022, 10:54 PM
RE: Fast filled circle - by mdijkens - 11-26-2022, 11:13 PM
RE: Fast filled circle - by bplus - 11-26-2022, 11:29 PM
RE: Fast filled circle - by SMcNeill - 11-27-2022, 01:44 AM
RE: Fast filled circle - by SMcNeill - 11-27-2022, 01:46 AM
RE: Fast filled circle - by gaslouk - 11-27-2022, 04:50 AM



Users browsing this thread: 5 Guest(s)