[solved]Change or transform an image already on the screen?

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
angelicdreamweaver
Newbie
Posts: 13
Joined: Tue Oct 24, 2023 6:01 pm
Contact:

[solved]Change or transform an image already on the screen?

#1 Post by angelicdreamweaver »

Can I refer to an already shown image that is constantly panning and change the tint afterwards at a specific point in the story?
Because of the panning, I cannot simply hide the image and show it again with the new tinting values.

So far, I came up with this, using an invisible white tint as a timer - but I don't know how many seconds the reader needs to arrive at the place where it should start to get darker around him.

Code: Select all

show bgroom at pan:
	linear 60 matrixcolor TintMatrix("#ffffff00")
	linear 10 matrixcolor TintMatrix("#fa8e60")
Last edited by angelicdreamweaver on Sat Dec 02, 2023 5:59 am, edited 1 time in total.

User avatar
m_from_space
Miko-Class Veteran
Posts: 888
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Change or transform an image already on the screen?

#2 Post by m_from_space »

angelicdreamweaver wrote: Fri Nov 24, 2023 5:59 am Because of the panning, I cannot simply hide the image and show it again with the new tinting values.
Actually, you can. Just use the "animation" keyword, so the panning animation isn't restarted.

Code: Select all

transform atl_tint:
    # make sure to put this here first, before changing it
    matrixcolor TintMatrix("#fff")
    # now change it
    linear 10.0 matrixcolor TintMatrix("#fa8e60")

transform atl_pan:
    animation
    xoffset 0
    # put your pan code here, e.g.
    linear 5.0 xoffset 500
    linear 5.0 xoffset 0
    repeat

label start:
    show myimage at atl_pan
    "Here we didn't arrive at the point in the story."
    show myimage at atl_tint, atl_pan
    "Now we just did..."
So far, I came up with this, using an invisible white tint as a timer.
The alpha channel is not touched with TintMatrix(), so there is no invisible tint. It's just that tinting with "#fff" (white) means no tinting at all.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2360
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Change or transform an image already on the screen?

#3 Post by Ocelot »

Fun fact: order of transforms at the second show is important. If you change order of those two, you will have problems.
Here is some information on replacing transforms and transform order: https://www.renpy.org/doc/html/atl.html ... transforms
< < insert Rick Cook quote here > >

User avatar
angelicdreamweaver
Newbie
Posts: 13
Joined: Tue Oct 24, 2023 6:01 pm
Contact:

Re: Change or transform an image already on the screen?

#4 Post by angelicdreamweaver »

m_from_space wrote: Sat Nov 25, 2023 5:37 am
Actually, you can. Just use the "animation" keyword, so the panning animation isn't restarted.
Nice, thank you! It almost works, though there is a noticeable jump forward by perhaps 100 pixel or so in the panning.
I am using "linear 333.0 xpan 360" and not xoffset. Adding the "xoffset 0" above didn't help, the two animations are not quite aligned in the timing - but almost. Weird...?

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2360
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Change or transform an image already on the screen?

#5 Post by Ocelot »

What I wrote in previous post is very important. Are you sure that previous image pan is replaced be a new image pan? If for the original image pan was the last transform applied, then for newly showed image it should be last transform applied too.
< < insert Rick Cook quote here > >

User avatar
angelicdreamweaver
Newbie
Posts: 13
Joined: Tue Oct 24, 2023 6:01 pm
Contact:

Re: Change or transform an image already on the screen?

#6 Post by angelicdreamweaver »

Ocelot wrote: Sat Nov 25, 2023 4:20 pm What I wrote in previous post is very important. Are you sure that previous image pan is replaced be a new image pan? If for the original image pan was the last transform applied, then for newly showed image it should be last transform applied too.
Well, I changed the order of the two transform calls behind "at" - and the result is the same: Both work well, the tint begins correctly, but both have that jump before.

Code: Select all

transform pan:
        animation
        subpixel True
        linear 333.0 xpan 360
        repeat

transform gettingdarker:
        matrixcolor TintMatrix("#fff")
        linear 10.0 matrixcolor TintMatrix("#fa8e60")
        
show bgroom at pan

### (some lines of narration)
        
show bgroom at pan, gettingdarker
# works the same: show bgroom at gettingdarker, pan

User avatar
m_from_space
Miko-Class Veteran
Posts: 888
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Change or transform an image already on the screen?

#7 Post by m_from_space »

angelicdreamweaver wrote: Sun Nov 26, 2023 8:11 amBoth work well, the tint begins correctly, but both have that jump before.
The reason is that you didn't set a default value for that property you are changing. You should always do that (the same reason you're doing it with the matrixcolor property). xpan wants a float by the way.

Code: Select all

transform pan:
    animation
    subpixel True
    xpan 0.0 # default value is important!
    linear 333.0 xpan 360.0
    repeat

User avatar
angelicdreamweaver
Newbie
Posts: 13
Joined: Tue Oct 24, 2023 6:01 pm
Contact:

Re: Change or transform an image already on the screen?

#8 Post by angelicdreamweaver »

m_from_space wrote: Sun Nov 26, 2023 8:36 am The reason is that you didn't set a default value for that property you are changing.
xpan wants a float by the way.
Thanks, I changed both... but it still does the same than before, that weird jump forward in the panning.

User avatar
m_from_space
Miko-Class Veteran
Posts: 888
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Change or transform an image already on the screen?

#9 Post by m_from_space »

angelicdreamweaver wrote: Sun Nov 26, 2023 12:35 pm
m_from_space wrote: Sun Nov 26, 2023 8:36 am The reason is that you didn't set a default value for that property you are changing.
xpan wants a float by the way.
Thanks, I changed both... but it still does the same than before, that weird jump forward in the panning.
Probably because of the wrong order like @Ocelot stated. Because on my end it works.

User avatar
angelicdreamweaver
Newbie
Posts: 13
Joined: Tue Oct 24, 2023 6:01 pm
Contact:

Re: Change or transform an image already on the screen?

#10 Post by angelicdreamweaver »

m_from_space wrote: Mon Nov 27, 2023 8:28 am Probably because of the wrong order like @Ocelot stated. Because on my end it works.
How weird! When I do it, it doesn't matter what order the transforms are called. I always have that jump foward during the panning. :roll:

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2360
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Change or transform an image already on the screen?

#11 Post by Ocelot »

Show you current code for both transforms and how you display it.
< < insert Rick Cook quote here > >


User avatar
Ocelot
Lemma-Class Veteran
Posts: 2360
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Change or transform an image already on the screen?

#13 Post by Ocelot »

Adding default value and fixing order of transform fixed the issue for me in the new project:

Code: Select all

transform pan:
    animation
    subpixel True
    xpan 0
    linear 33.0 xpan 360
    repeat

transform gettingdarker:
    matrixcolor TintMatrix("#fff")
    linear 10.0 matrixcolor TintMatrix("#fa8e60")
        
label start:
    show bg room  at pan
    "well..."
    show bg room  at gettingdarker, pan
    "333"
    return
< < insert Rick Cook quote here > >

User avatar
angelicdreamweaver
Newbie
Posts: 13
Joined: Tue Oct 24, 2023 6:01 pm
Contact:

Re: Change or transform an image already on the screen?

#14 Post by angelicdreamweaver »

I actually did have the xpan 0 in there as well. Now when I tested it again, copying the lines in the same place, it worked fabulous. Don't know what was wrong before. :roll: Thank you! :D

Post Reply

Who is online

Users browsing this forum: jeffster