Improved my small Gradient Ball drawing SUB
#7
Thanks, mnrvovrfc.

Here's another version I played around with today, using SQR + PSET.  Added transparency.  Small, but slower though.

- Dav

Code: (Select All)

SCREEN _NEWIMAGE(800, 600, 32)

DO
    ball RND * _WIDTH, RND * _HEIGHT, RND * 400 + 25, RND * 255, RND * 255, RND * 255, 100 + RND * 155
    _LIMIT 5
LOOP UNTIL INKEY$ <> ""

SUB ball (x, y, size, r, g, b, a)
    FOR y2 = y - size TO y + size
        FOR x2 = x - size TO x + size
            clr = (size - (SQR((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y)))) / size
            IF clr > 0 THEN PSET (x2, y2), _RGBA(clr * r, clr * g, clr * b, a)
        NEXT
    NEXT
END SUB

Find my programs here in Dav's QB64 Corner
Reply


Messages In This Thread
RE: Improved my small Gradient Ball drawing SUB - by Dav - 07-11-2023, 05:35 PM



Users browsing this thread: 6 Guest(s)