[Solved] Recently got into Ren'Py, need some information on Image Manipulators

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
Koya-Sato
Newbie
Posts: 4
Joined: Fri Jan 12, 2018 4:33 pm
Location: United States
Contact:

[Solved] Recently got into Ren'Py, need some information on Image Manipulators

#1 Post by Koya-Sato »

Alright peebles, so I have two things that I could really use answers for if anyone's willing to lend me a hand for a moment. (*´▽`*)

The first thing that I'd like to know is how to call up one image manipulator within another image manipulator.
For example, if I wanted to to vertically flip an image and then also horizontally flip it, how would I write that out?

Currently I only know how to do this directly to the image itself like in the following examples:

Code: Select all

image whateverfliph = im.Flip("whatever.png", horizontal=True)
image whateverflipv = im.Flip("whatever.png", vertical=True)
I haven't tried yet, but I suppose that something like

Code: Select all

image whateverfliphv = im.Flip("whatever.png", horizontal=True, vertical=True)
might work in this instance.

Even if the above DOES work, I still don't know how I can refer to an entirely separate type of image manipulator, such as if I was flipping a scaled image, for example.
I don't have any idea as to what the proper syntax for something like that is, which should go a long way towards exposing my ignorance.

Secondly; I came up with what is probably the most rudimentary way of going about this, but I need to find an efficient way of increasing and decreasing individual character brightness with some form of dynamic control (even better if it allows me to tweak the RGB values as well to tint the image).

My current solution to this is:

Code: Select all

image characterdark = im.MatrixColor(
    "generic_folder/character.png",
    im.matrix.tint(0.6, 0.6, 0.7))
the above darkening the character about 33% and giving them a slight blue tint as if they're in a cave or something.

This works fine for single image poses, but
1. I don't know how to make a single command affect multiple images, meaning that this is the least efficient command in the universe for Ren'py basically
2. There's probably significantly more efficient ways of doing this where I don't need to designate each individual pose with a proper lighting code, basically just an on/off switch that designates whether all characters or individual characters are affected and to what extent

Having to encode each pose being darkened individually would be an extreme hassle, not even going into how absurd it could get if I tried to use my current solution for coloring every individual character image separately.

TLDR Summary Σ(‘◉⌓◉’)
-I need to know how to reference one (or more) image manipulators within another image manipulator's syntax
-I need to know how to include multiple images within a single user-defined command when it comes to altering their colors (although this will obviously work with other stuff too)
-I would like a more efficient way to set brightness/tint/contrast for characters within a scene rather than on a pose-by-pose basis

Hopefully I was concise with my language and I get the point across.
Please and thank you, kind minds of the internet, for I am at your mercy. _/\○_
Last edited by Koya-Sato on Tue Jan 16, 2018 5:31 pm, edited 5 times in total.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3791
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Recently got into Ren'Py, need some information on Image Manipulators

#2 Post by Imperf3kt »

Ren'Py's ATL function is your friend.
I don't currently have much time to go over it in detail, but have a look at the documentation on it and if you get stuck, don't hesitate to ask! I'll (or someone else) reply when I can.
https://www.renpy.org/doc/html/atl.html
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
Donmai
Eileen-Class Veteran
Posts: 1960
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
Projects: Slumberland
Location: Brazil
Contact:

Re: Recently got into Ren'Py, need some information on Image Manipulators

#3 Post by Donmai »

Although the Ren'Py internal function im.flip() will work, it's old stuff. As Imperf3kt mentioned, ATL makes things easier and it's faster too. To flip an image using ATL you just give a negative value to the xzoom or yzoom transforms. For example, if you have an image called "eillen happy.png" in your images folder you can either define a flipped version of that image:

Code: Select all

image eileen_mirrored:
    "eillen happy"
    xzoom -1.0
or simply use the show statement when needed:

Code: Select all

show eillen happy:
    xzoom -1.0
It's even possible to create a transform and use it for flipping animations: viewtopic.php?p=394009#p394009
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

User avatar
ComputerArt.Club
Veteran
Posts: 427
Joined: Mon May 22, 2017 8:12 am
Completed: Famous Fables, BoPoMoFo: Learn Chinese, Santa's workshop, Cat's Bath, Computer Art Club
Location: Taiwan
Contact:

Re: Recently got into Ren'Py, need some information on Image Manipulators

#4 Post by ComputerArt.Club »

I hope you don't mind if I post PyTom's solution for your second problem (as posted on Discord). It may be useful for others in the future.

Code: Select all

init python:

     def dark(d):

          return im.MatrixColor(d,  im.matrix.tint(0.6, 0.6, 0.7))

image characterdark =  dark("generic_folder/character.png")

User avatar
Koya-Sato
Newbie
Posts: 4
Joined: Fri Jan 12, 2018 4:33 pm
Location: United States
Contact:

Re: Recently got into Ren'Py, need some information on Image Manipulators

#5 Post by Koya-Sato »

Imperf3kt wrote: Sat Jan 13, 2018 3:00 am Ren'Py's ATL function is your friend.
Thanks for the link, the Wiki seems to have a big mix of old and new information and it makes it a little difficult to figure out what I should be using. 「(゚ペ)
Donmai wrote: Sat Jan 13, 2018 9:14 am

Code: Select all

image eileen_mirrored:
    "eillen happy"
    xzoom -1.0
Aha! (•̀o•́)ง <( i get it! )
That makes sense, thanks a lot for explaining that bit.
ComputerArt.Club wrote: Sat Jan 13, 2018 9:32 am I hope you don't mind if I post PyTom's solution for your second problem (as posted on Discord). It may be useful for others in the future.
I actually meant to do that myself but I was so excited to get around to doing what I needed that it completely slipped me mind, thanks a bunch! ٩(๑❛ワ❛๑)و

Considering PyTom's solution for me I guess there isn't an easy way to change the color/brightness of all character images like an "on/off" switch, which means that this topic has reached its conclusion.
Could someone append [Solved] to the title for me please? Or is that something I can do and I'm just a dummy that doesn't see a way to do that? (ˊᗜˋ*)

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3791
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Recently got into Ren'Py, need some information on Image Manipulators

#6 Post by Imperf3kt »

You can do it by simply editing the first post and adding it to the title while editing.
That way all future posts will include it and it'll appear as so in the search.

This trick works on most forums.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], decocloud, Google [Bot]