Improved my small Gradient Ball drawing SUB
#23
I like it, James!  Neat wiggle motion.  Seems to update quickly too.  I'll have to study that a while.  Thanks for sharing.

I was playing around this morning with adding a plasms texture to the gradient ball.  Here's a growing plasma ball.  Had to use the STEP/LINE trick to make it faster - PSETing it was too slow on my laptop.

- Dav

Code: (Select All)

'Growing Plasma ball
'by Dav, JULY/2023

SCREEN _NEWIMAGE(1000, 650, 32)

x = _WIDTH / 2 'x place of ball
y = _HEIGHT / 2 ' y place of ball
size = 45 'ball start size


DO
    t = TIMER
    FOR y2 = y - size TO y + size STEP 3
        FOR x2 = x - size TO x + size STEP 3
            IF SQR((x2 - x) ^ 2 + (y2 - y) ^ 2) <= size THEN
                clr = (size - (SQR((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y)))) / size
                noise = INT(RND * 75)
                r = SIN(6.005 * t) * size - y2 + size + 255
                g = SIN(3.001 * t) * size - x2 + size + 255
                b = SIN(2.001 * x2 / size + t + y2 / size) * r + 255
                LINE (x2, y2)-STEP(2, 2), _RGBA(clr * r - noise, clr * g - noise, clr * b - noise, 5 + RND * 10), BF
            END IF
        NEXT
        t = t + .01
    NEXT
    IF size < y THEN size = size + .5
    _LIMIT 60
    _DISPLAY
LOOP



EDIT:  A little variation - ball grows & shrinks randomly, leaving gassy like edges. Looks less like a ball.

Code: (Select All)

SCREEN _NEWIMAGE(1000, 650, 32)

x = _WIDTH / 2 'x place of ball
y = _HEIGHT / 2 ' y place of ball
size = 45 'ball start size


DO
    t = TIMER
    FOR y2 = y - size TO y + size STEP 3
        FOR x2 = x - size TO x + size STEP 3
            IF SQR((x2 - x) ^ 2 + (y2 - y) ^ 2) <= size THEN
                clr = (size - (SQR((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y)))) / size
                noise = INT(RND * 50)
                r = SIN(6.005 * t) * size - y2 + size + 255
                g = SIN(3.001 * t) * size - x2 + size + 255
                b = SIN(2.001 * x2 / size + t + y2 / size) * r + 255
                LINE (x2, y2)-STEP(2, 2), _RGBA(clr * r - noise, clr * g - noise, clr * b - noise, 5 + RND * 10), BF
            END IF
        NEXT
        t = t + .01
    NEXT

    LINE (0, 0)-(_WIDTH, _HEIGHT), _RGBA(0, 0, 0, 10), BF

    IF INT(RND * 2) = 1 THEN size = size + (RND * 15) ELSE size = size - (RND * 15)
    IF size < y THEN size = size + .5
    IF size > (y * 1.5) THEN size = y
    IF size < 15 THEN size = 15

    _LIMIT 60
    _DISPLAY
LOOP


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-13-2023, 05:23 PM



Users browsing this thread: 10 Guest(s)