Home Artists Posts Import Register

Content

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!

For this first of 15 days of Bach portraits, let's talk about how I'm rendering Bach's face!

First things first, we need some reference data! So let's snatch a portrait of Bach off Google Pictures and cut out the face and hair.

Now import that cutout in Pico-8 and write a tiny program that will generate a long string that registers the shapes' borders on each line of the screen. The string takes the form of a lua table initialization and it is exported with printh(str,"@clip"), directly to the clipboard! Here's a short excerpt of what it looks like:

<code><code>
face_cutout={[22]={67,75},[23]={62,76},[24]={59,79},[25]={57,83},[26]={55,84},[27]={53,84},[28]={51,85},[29]={50,87},[30]={50,88},....}
</code></code>

Pico-8 makes a great scripting tool when you want to format or generate formatted data strings like this!

From there, we can use these few lines to render the shapes:

<code><code>
for y,xs in pairs(face_cutout) do
local i=1
while i<#v do
 local xa,xb=xs[i],xs[i+1]
 rectfill(xa,y,xb,y,15)
 i+=2
end
end
</code></code>

And that will give you an amazing feature-less wax reproduction of Bach's face! So now the features!

I just love how that looks.

Yes, the features are simply sprites made as close as I could to the original portrait I showed you above. Now I only have to draw them at the right coordinates and we have our Bach portrait!

But of course that's not it! In this first animated Bach portrait, I'm dynamically scaling Bach's face up and down!

Don't worry though, for it is but another simple trick, mainly based on this function:

<code><code>
function dis(n)
return (n-64)*fac+64
end
</code></code>

This function, ('dis', short for 'displace', because of course 8 letters is too long) will move any value towards the center of the screen (64;64) by the factor 'fac', a global variable.

With this function, the cut-out rendering snippet from above becomes this:

<code><code>
for y,xs in pairs(face_cutout) do
local y=dis(y)
local i=1
while i<#xs do
 local xa,xb=dis(xs[i]),dis(xs[i+1])
 rectfill(xa,y,xb,y,15)
 i+=2
end
end
</code></code>

Each line of our cutout is displaced towards the center of the screen, and so are the x coordinates that are stored in it.

For the sprites, we use sspr(sx, sy, sw, sh, dx, dy, dw, dh) to scale them and we displace them as well.

There is yet a little more to it than that, with the moving fill-patterns and the lighting effect mainly, but for those, you'll have to dig into the source files yourself, available to my 5$+ supporters through this link!

Thank you for reading! I hope you're looking forward to the other 14 portraits!

Here's a silly bonus screenshot I took while working on this portrait!

Take care!

TRASEVOL_DOG

Files

Invention No. 1 in C Major, BWV 772 (Pico-8 Edition)

Invention No. 1 in C Major, BWV 772 composed by J.S. Bach (1685-1750). Music arrangement by Gruber (@gruber_music) Artwork/Animation/Code by Trasevol_Dog (@TRASEVOL_DOG) Support us on Patreon! https://www.patreon.com/Gruber99 https://www.patreon.com/trasevol_dog Arranged and animated in Pico-8. Pico-8 is a fantasy console for making, sharing and playing tiny games and other computer programs. https://www.lexaloffle.com/pico-8.php

Comments

No comments found for this post.