Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Another small filled circe sub (not as fast as fcirc)
#39
(08-30-2024, 02:17 PM)bplus Wrote: Steve yours has same flaw as Dav's FC4 from which you made youirs

Code: (Select All)
Screen _NewImage(1200, 700, 32)
_Define A-Z As LONG
Dim Shared CircleXPos(500, 500)
PreCalcX

StevePreCalcCircle 600, 350, 300, _RGB32(0, 0, 255, 100)

Sub StevePreCalcCircle (cx, cy, r, clr&)
    $Checking:Off
    For y = 0 To r
        x = CircleXPos(r, y)
        Line (cx - x, cy - y)-(cx + x, cy - y), clr&, BF
        Line (cx - x, cy + y)-(cx + x, cy + y), clr&, BF
    Next
    $Checking:On
End Sub

Sub PreCalcX
    For r = 0 To 500 'circles with a radius from 0 to 500
        r2 = r * r
        For y = 0 To r
            y2 = y * y
            x = Int(Sqr(r2 - y2))
            CircleXPos(r, y) = x
        Next
    Next
End Sub

Does not work for transparent colors.

Both Steve and Pete are also using Dav's messed up FC3 code.

I've already pointed out these 2 things with Dav's code.

Aye.  I wasn't trying to make an image perfect circle.  I was simply testing the concept of how much a precalculated-point system would speed up a circle.

What we have is already quick enough and optimized enough for my needs.   The time difference in these routines is really fairly negligible under most use cases.  It shouldn't be too difficult to adjust that to accommodate for the overlap.

Code: (Select All)
Sub StevePreCalcCircle (cx, cy, r, clr&)
    $Checking:Off
    For y = 0 To r
        x = CircleXPos(r, y)
        Line (cx - x, cy - y)-(cx + x, cy - y), clr&, BF
        IF y > 0 THEN Line (cx - x, cy + y)-(cx + x, cy + y), clr&, BF
    Next
    $Checking:On
End Sub

Something as simple as the above should fix it, I'd think -- though it's untested.  The concept, at least, seems sound to me:  If your +y and -y are 0, then you only need to draw the line once, not twice.
Reply


Messages In This Thread
RE: Another small filled circe sub (not as fast as fcirc) - by SMcNeill - 08-30-2024, 02:24 PM



Users browsing this thread: 29 Guest(s)