Ren’py How To: Recoloring Sprites

It’s been a little while since our last “how to” post, and today we’re revisiting an oldie but a goodie – recoloring sprites inside Ren’py using Matrix Color!

As you know, we have an older post up with some details on how to do this, but the process is quite long and messy – you end up having to add the matrix to every single piece of your layeredimage, which is just too much of a hassle!

Now, I have two brand new ways to show you how to do it quicker and easier. Firstly, why don’t we start with an example of what recoloring sprites could be used for…

…Tada! We use it a lot in The Divine Speaker to further enhance the ambience of our night and sunset backgrounds. Making the sprites blend further into the background really helps the game to look more professional.

There’s two ways I’m going to go over, and it’s totally up to you which one you want to use. 

Using LayeredImageProxy

Firstly, you’ll define your layered image sprite as normal:

layeredimage noah:

    always:
        "images/Sprites/noah/noah_n_base.png"
        
    group face:
        attribute ang:
            "/images/sprites/noah/noah_n_ang.png"
        attribute hap:
            "/images/sprites/noah/noah_n_hap.png"
        attribute hur:
            "/images/sprites/noah/noah_n_hur.png"

    group hair:
        attribute hair default:
         "images/Sprites/noah/noah_n_hair.png"
 

Then, we define the tint matrix:

define dim_matrix = TintMatrix(Color(rgb=(.90,.90,1)))*BrightnessMatrix(-0.1)
define dark_matrix = TintMatrix(Color(rgb=(.44,.54,.75)))*BrightnessMatrix(-0.07) 

You can play with these numbers and add different recolors, too!

Lastly, we apply the tint matrix to the sprites:

image noah dim = LayeredImageProxy("noah", Transform(matrixcolor=dim_matrix)) 
image noah dark = LayeredImageProxy("noah", Transform(matrixcolor=dark_matrix))
 

And that’s it! You can call your sprites as normal, i.e. “show noah ang” will show the normal color, while “”show noah dark ang” will show the dark sprite.

Using a Transform

You can use both this option and the option above, if you fancy!

First, we start by adding the layered image the same as above:

layeredimage noah:

    always:
        "images/Sprites/noah/noah_n_base.png"
        
    group face:
        attribute ang:
            "/images/sprites/noah/noah_n_ang.png"
        attribute hap:
            "/images/sprites/noah/noah_n_hap.png"
        attribute hur:
            "/images/sprites/noah/noah_n_hur.png"

    group hair:
        attribute hair default:
         "images/Sprites/noah/noah_n_hair.png" 

Then, we create a transform:

transform dark_tint:
    matrixcolor TintMatrix(Color(rgb=(.90,.90,1)))*BrightnessMatrix(-0.1)
    
transform dim_tint:
    matrixcolor TintMatrix(Color(rgb=(.90,.90,1)))*BrightnessMatrix(-0.1) 

Then, we just call it as follows:

show noah ang at dark_tint

# You can also use it with other positions
show noah ang at dark_tint, right 

And that’s it! 

 

Like I said above, you can use both in combination – I find it useful to have my sprites set up using LayeredImageProxy, and keep the transform for other graphics (like BGs, CGs, etc!).

Hope you get some use out of this and it saves you all some time.

 

Got any questions you want us to answer?

Ren’py How To: Recoloring Sprites
Scroll to top
Join Waitlist We will inform you when the product arrives in stock. Please leave your valid email address below.