Layering images

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
RedSlash
Veteran
Posts: 351
Joined: Sun Oct 31, 2004 12:48 am
Location: Canada
Contact:

Layering images

#1 Post by RedSlash »

Does renpy support layering of images, that is to compose an image by layering multiple images on top of each other?

User avatar
PyTom
Ren'Py Creator
Posts: 16088
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

#2 Post by PyTom »

Yes. Just show multiple images.

Code: Select all

scene whitehouse
show eileen happy
show lucy happy
The pictures are shown with the newest on top. You can only have one picture with a given prefix (first part of the name) on screen at once, and showing a second picture with the same prefix places the new picture at the same point in the order as the old one.

So if I do a:

Code: Select all

show eileen upset
Lucy will still be on top of her. Hope this helps.

Tage
Regular
Posts: 194
Joined: Mon Nov 01, 2004 2:18 am
Location: Memphis, TN
Contact:

#3 Post by Tage »

Maybe RedSlash means, a transparent image that is placed over a faceless "model" to change the expression of a character while using less disk space at the same time. Sorry if that's what you just answered, but it didn't seem like it to me. :?

User avatar
PyTom
Ren'Py Creator
Posts: 16088
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

#4 Post by PyTom »

Oh.

The answer to that question is "not really". I'm sure one could do it with enough careful programming, but Ren'Py doesn't make it easy. I didn't see much of a need, as computer nowadays have enough ram and disk space to make this not worth the added complexity.

This is the same reason why I don't support color-keyed images, but instead only support formats with actual alpha channels, like PNG.

RedSlash
Veteran
Posts: 351
Joined: Sun Oct 31, 2004 12:48 am
Location: Canada
Contact:

#5 Post by RedSlash »

Opps sorry, I guess I should've explained in more detail. Yeah, I meant to do what Tage is saying. But I just wanted to know if I could just slap layers of images on top of each other in general cause there might be other uses for that too. I didn't specifically say color-keying, but if the use of transparent PNGs on top of each other achieves the same effect, then thats fine.

People may have plentiful disk space around, but they may not have high speed modems though. I personally like to keep files small and save whenever I can.

User avatar
PyTom
Ren'Py Creator
Posts: 16088
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

#6 Post by PyTom »

Yeah, I thought about that. Theoretically, one could come up with a script that precomputed images from layers when the game was installed. This might save space on the download, but I'm not sure how much, if it would be enough to be worth it.

Grey
Veteran
Posts: 320
Joined: Thu Jan 01, 2004 8:08 am
Contact:

#7 Post by Grey »

More than download size it means that the artist just has to edit one body if a change needs to be made.

If the expression isn't seperate then it means copying and pasting, resizing etc the same thing for however many expressions the character has.

User avatar
rioka
Royal Manga Tutor
Posts: 1255
Joined: Fri Jul 16, 2004 12:21 pm
Completed: Amgine Park, Garden Society: Kykuit, Metropolitan Blues (art)
Location: somewhere in NY
Contact:

#8 Post by rioka »

Actually, RenPy can do what RedSlash wants to accomplish. The Love Revo system is based on a paperdoll method and it works fine on RenPy. (We're currently putting together the demo's on RenPy as our own engine is not finished.)

It saves a lot of space doing it the paperdoll method. Consider this: you have 4 expressions: neutral, happy, mad, sad. If it was the complete person, it could run about say 15KB per image. Total: 60KB. Now, take that and add in all the different outfits (let's say 4), it runs to 240KB.

Now, if you do the paperdoll method, you get 12KB for the body base, around the same for the each clothing at 12KB each, totaling 60KB. Each expression is about 8 KB, let's say. Grand total = 92KB.

It may not seem a lot but once you make something with a lot of characters or have high quality character images - it helps a lot.

User avatar
PyTom
Ren'Py Creator
Posts: 16088
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

#9 Post by PyTom »

Well, I'm convinced. I just added layer support to the latest version of Ren'Py. Basically, if you create an image using a constructor like:

Code: Select all

init:
    image eileen happy beret = Image(("9a_happy.png", "beret.png"))
Ren'Py 4.4 will now layer the images together. What's more, it will precompute the merged image, which should speed up performance over the layered approach.

I didn't know Love Revo was using Ren'Py, at least for a demo.

And in other news, dentistry is significantly less fun when the Novicane just doesn't work on you.

RedSlash
Veteran
Posts: 351
Joined: Sun Oct 31, 2004 12:48 am
Location: Canada
Contact:

#10 Post by RedSlash »

Can you specify the position of the second layered image? Cause the second image may be smaller size, but you need to specify an offset to display it.

User avatar
PyTom
Ren'Py Creator
Posts: 16088
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

#11 Post by PyTom »

Not as of right now. The images are aligned to the upper-left corner of the base image. Since transparent areas compress really well, I think that this is an acceptible compromise that also keeps the feature fairly easy to use. (The idea is that the various paper doll parts will be the same size as the character, and so will align to the right spot without the user needing to get into pixel-by-pixel positioning.)

User avatar
rioka
Royal Manga Tutor
Posts: 1255
Joined: Fri Jul 16, 2004 12:21 pm
Completed: Amgine Park, Garden Society: Kykuit, Metropolitan Blues (art)
Location: somewhere in NY
Contact:

#12 Post by rioka »

Wow, thanks PyTom! That'll make things a whole lot easier. ^_^

We just decided on using RenPy fairly recently for Love Revo as both demo's have been coming along lately.
PyTom wrote:(The idea is that the various paper doll parts will be the same size as the character, and so will align to the right spot without the user needing to get into pixel-by-pixel positioning.)
Yup, that's what we're basically doing. All the expression's look like floating heads if viewed on their own. XD

User avatar
PyTom
Ren'Py Creator
Posts: 16088
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

#13 Post by PyTom »

Cool. Let me know if there's any features that the Love Revo folks want. I've penciled the next release for Christmas, which gives me a day or two to add the new stuff.

Ishigreensa
Newbie
Posts: 20
Joined: Sun Jul 06, 2014 8:11 am
Contact:

Re: Layering images

#14 Post by Ishigreensa »

Can I....
Say have a background layer on a layeredimage:
then position layered attributes and groups within the layer, where I want different characters to appear?
But not use images separately:

Like this?
layeredimage schoolfront:
always:
"images/bg/schoolfront.png"
if coach:
"images/teachers/coach/[face]_[arms]_base.png":
pos(800,250)

would this work?

Post Reply

Who is online

Users browsing this forum: Google [Bot], Kocker, Majestic-12 [Bot]