Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Another small filled circe sub (not as fast as fcirc)
#80
Ok. So, I did some research and figured out that the FC_Gold (a.k.a. FC0) performs well because it avoids the branching (ELSE part) inside the main loop. I made some modifications to optimize it even further. It avoids some unnecessary things keeping in mind not to overdraw pixels and hence not screwing up alpha blending.

Code: (Select All)
SUB DrawFilledCircle (cx AS LONG, cy AS LONG, r AS LONG, c AS _UNSIGNED LONG)
    $CHECKING:OFF

    IF r <= 0 THEN
        PSET (cx, cy), c
        EXIT SUB
    END IF

    DIM e AS LONG: e = -r
    DIM x AS LONG: x = r
    DIM y AS LONG

    LINE (cx - x, cy)-(cx + x, cy), c, BF

    DO WHILE x > y
        y = y + 1
        e = e + y * 2

        IF e >= 0 THEN
            IF x <> y 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
            e = e - x * 2
        END IF

        LINE (cx - x, cy - y)-(cx + x, cy - y), c, BF
        LINE (cx - x, cy + y)-(cx + x, cy + y), c, BF
    LOOP

    $CHECKING:ON
END SUB
Reply


Messages In This Thread
RE: Another small filled circe sub (not as fast as fcirc) - by a740g - 09-01-2024, 02:23 AM



Users browsing this thread: 15 Guest(s)