How to make the bloom effect


First of all I want to say that I didn't came up with the bloom effect. I saw a tweetcart with a very similar effect a couple of years ago and recreated it from memory (the original used different colors, but the idea was the same).

If someone finds the original please send it to me so I can give proper credit. I spent 2 hours searching for it, but twitter is terrible for finding things that aren't recent.

Anyways, here's my implementation. Have fun!

rose_colors = {1,8,9,10,12}
leaf_colors = {3,11}

-- picks a random value from an array
function rnd_arr(arr)
    return arr[flr( rnd(#arr) ) + 1]
end

-- colors the pixel in the given position the color of wood
function wood(x, y)
    local c = pget(x,y)
    if c < 3 then
        pset(x,y,15)
    end
end

-- spawns a rose in the given position
function rose(x, y)
    circ(x, y, 1, rnd_arr(rose_colors) )
end
-- spawns a leaf in the given position
function leaf(x, y)
    circ(x, y, 1, rnd_arr(leaf_colors) )
end


-- algorithm starts --
cls()
-- draw initial shapes
-- the color 15 is the one where things can spawn or change
circ(64, 64, 32, 15)

::_::
-- pick random pixel on the screen and get its color
x = rnd(128)
y = rnd(128)
c = pget(x,y)

if c == 15 then
    -- pick a neighbour pixel
    x1 = x + rnd(2)-1
    y1 = y + rnd(2)-1

    -- i chose the following values through trial and error until i was happy with them
    -- feel free to modify them
    if rnd() < 0.92 then
        wood(x1, y1)
    else
        if rnd() < 0.1 then
            rose(x1, y1)
        else
            leaf(x1,y1)
        end
    end
    
    if rnd() < 0.2 then
        local r = rnd()
        if r < 0.4 then
            pset(x,y,4)
        elseif r < 0.8 then
            pset(x,y,2)
        else
            leaf(x,y)
        end
    end
end
goto _

Get Touch Light

Download NowName your own price

Comments

Log in with itch.io to leave a comment.

Thank you so much!

OMGGGG! Thank you so much for sharing the effect!! :3
Weewooo gonna make things bloom in my carts 💖🌻