im.MatrixColor Questions

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Milkymalk
Miko-Class Veteran
Posts: 753
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

im.MatrixColor Questions

#1 Post by Milkymalk »

1. While trying different im.MatrixColor effects I found im.matrix.identity(), which returns a matrix filled with 1s, doing nothing to an image it is applied to. Can you give me an example what I would use this for?

2. How would I use matrix effects for setting the hue of an image, leaving the brightness and saturation alone? im.matrix.hue rotates the hue, so it's not what I am after. In short, if I set the hue to, say, red, then white should stay white, black should stay black, and all shades of color should be set to the red hue. im.matrix.tint doesn't help as it affects saturation, and if I need a matrix for the MatrixColor, I can't figure out the numbers.
2b. Apparently, what I want is akin to the "soft light" layer mode found in graphics software. Is that possible? I have doubts, because all formulas I could find are more complicated than a*b, which is all MatrixColor can do.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

User avatar
qirien
Miko-Class Veteran
Posts: 541
Joined: Thu Jul 31, 2003 10:06 pm
Organization: Metasepia Games
Deviantart: qirien
Github: qirien
itch: qirien
Location: New Mexico, USA
Discord: qirien
Contact:

Re: im.MatrixColor Questions

#2 Post by qirien »

1) I'm not sure when you would need it.

2) I am not sure exactly what you are trying to do, but here is some code that turns a sprite orange:

Code: Select all

image him orange = im.MatrixColor("him happy.png",  im.matrix.tint(0.9, 0.7, 0.3))
...and some that turns a sprite green, but it desaturates it first:

Code: Select all

renpy.image("sprite green", im.MatrixColor("sprite.png", im.matrix.desaturate() * im.matrix.tint(0.7, 1.0, 0.7)))
Is one of these kind of what you want?
Finished games:
Image
Image
Image

User avatar
Milkymalk
Miko-Class Veteran
Posts: 753
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: im.MatrixColor Questions

#3 Post by Milkymalk »

Unfortunately not, because im.matrix.tint turns white into the tint color. What I want is to preserve brightness and saturation ("strength" of color), only changing the hue (which color it is).
I know there is im.matrix.hue(), but that rotates the hue a certain degree instead of setting it fix to a value.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

User avatar
qirien
Miko-Class Veteran
Posts: 541
Joined: Thu Jul 31, 2003 10:06 pm
Organization: Metasepia Games
Deviantart: qirien
Github: qirien
itch: qirien
Location: New Mexico, USA
Discord: qirien
Contact:

Re: im.MatrixColor Questions

#4 Post by qirien »

Do you have some way to store what color you're currently on, and then you could calculate what to pass to im.matrix.hue() based on that? Can you give a few more details -- maybe there's another way to go about it?
Finished games:
Image
Image
Image

User avatar
Milkymalk
Miko-Class Veteran
Posts: 753
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: im.MatrixColor Questions

#5 Post by Milkymalk »

Unfortunately not, I would have to analyze every single image that I want to use with this.

I did some research and found several formulas for the "soft light" layer effect. As it seems, it's necessary to reference the color values in order to apply this effect, and there's no way to do that in RenPy. Maybe it could be done by packing the whole formula into the matrix, but the result would be a monstrosity unlike any we have seen in RenPy so far.
I think I will tackle this detail in my game differently.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

Post Reply

Who is online

Users browsing this forum: bilmem, Bing [Bot], Google [Bot]