Pico-8 Bach Inventions Effects ~ Day 14: Sunset Sky Gradient
We are releasing one Bach Invention portrait every day for 15 days, with Chris (Gruber_music) who remade the musics in Pico-8. (I can't prove it yet, but I'm fairly certain he used some form of black magic)

Hi everyone!

The 14th Bach portrait features a sunset gradient in the background! Let's see how I made that!

First, you'll need an array of the colors you want in your gradient! You should repeat the colors several times in the array in relation to how much they should appear in the gradient. All the while keep in mind that each color will take up 8 pixels in height. Have a big enough array so that it will cover the gradient area you want.

In this portrait, my array of colors looks like this:

`<code>local cols={9,10,15,15,12,12,12,12,1,1}</code>`

Next, you want an array of fill patterns! You need four patterns, every one more dense than the next. You can actually use whatever pattern you want, as long as they get less dense as you go down the array. Here are what the patterns I used look like:

`<code>0 1 1 1 | 0 1 1 0 | 0 1 0 0 | 0 0 0 01 0 1 1 | 0 0 1 1 | 0 0 1 0 | 0 0 1 01 1 0 1 | 1 0 0 1 | 0 0 0 1 | 0 0 0 11 1 1 0 | 1 1 0 0 | 1 0 0 0 | 0 0 0 0</code>`

From there, all you have to do is iterate through your array of colors and for each pair of colors, iterate through the patterns and draw them with a rectfill with 2 pixels of height, always moving up by 2 pixels increments.

`<code>local y=64for i=0,#cols-2 do color(cols[i+1]*16+cols[i+2]) for j=0,3 do  fillp(ptrns[j+1])  rectfill(0,y,127,y-1)  y-=2 endend</code>`

And there you have it! A nice, soothing sunset (or any other time of the day, just change the colors) sky gradient!

Thank you for reading! Questions and remarks are both very welcome!

As usual, the downloads for this portrait are available to my 5\$+ supporters over there!

Take care and have a nice week-end!

TRASEVOL_DOG

### Become a patron to

130
Unlock 130 exclusive posts
Be part of the community
Connect via private message