Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Another small filled circe sub (not as fast as fcirc)
#67
That reminds me of fcirc4 in the Speed Tests we did years ago that I posted above where Sammy found Vince's contender.

Here it is isolated in slow mo
Code: (Select All)
_Title "Square filled center Circle Fill technique" ' b+ mod 2024-08-31
Screen _NewImage(800, 600, 32)
fCirc4 400, 300, 290, _RGB32(0, 0, 255, 100) ' <<<<<<<< using transparent color to check for overlapping lines
Sleep

'fCirc but doing octants until get to square, then just do square fill! 1.18 Gold Sdt
'this is closer to matching the Gold Standard
Sub fCirc4 (xx As Long, yy As Long, r As Long, K As _Unsigned Long)
    Dim r2 As Long, t As Long, dist As Long, tstop As Long
    r2 = r * r
    t = r 'r - 1 gets rid of nipples but...
    tstop = r * .707106781
    While t > tstop 'remove FOR loop
        dist = Sqr(r2 - t * t) ' + .5 for rounding down
        Line (xx - t, yy + dist)-(xx - t, yy - dist), K, BF
        Line (xx + t, yy + dist)-(xx + t, yy - dist), K, BF
        Line (xx + dist, yy + t)-(xx - dist, yy + t), K, BF
        Line (xx + dist, yy - t)-(xx - dist, yy - t), K, BF
        t = t - 1
        _Limit 30 ' to show off construction
    Wend
    Line (xx - tstop, yy - tstop)-(xx + tstop, yy + tstop), K, BF
End Sub

You can see there are no missing pieces with your test of different radii, you can also see what happens with overlapping lines from overlapping circles
Code: (Select All)
_Title "Square filled center Circle Fill technique" ' b+ mod 2024-089-31
Screen _NewImage(1024, 512, 32)
Cls
For x% = 0 To 49
    fCirc4 (x% Mod 10) * 100 + 50, (x% \ 10) * 100 + 50, x% + 10, _RGB32(0, 128, 0, 100)
Next x%

'fCirc but doing octants until get to square, then just do square fill! 1.18 Gold Sdt
'this is closer to matching the Gold Standard
Sub fCirc4 (xx As Long, yy As Long, r As Long, K As _Unsigned Long)
    Dim r2 As Long, t As Long, dist As Long, tstop As Long
    r2 = r * r
    t = r 'r - 1 gets rid of nipples but...
    tstop = r * .707106781
    While t > tstop 'remove FOR loop
        dist = Sqr(r2 - t * t) ' + .5 for rounding down
        Line (xx - t, yy + dist)-(xx - t, yy - dist), K, BF
        Line (xx + t, yy + dist)-(xx + t, yy - dist), K, BF
        Line (xx + dist, yy + t)-(xx - dist, yy + t), K, BF
        Line (xx + dist, yy - t)-(xx - dist, yy - t), K, BF
        t = t - 1
        _Limit 30 ' to show off construction
    Wend
    Line (xx - tstop, yy - tstop)-(xx + tstop, yy + tstop), K, BF
End Sub

In timed tests it did come close to Gold Standard
b = b + ...
Reply


Messages In This Thread
RE: Another small filled circe sub (not as fast as fcirc) - by bplus - 08-31-2024, 01:36 PM



Users browsing this thread: 16 Guest(s)