Zooming ATL displayables that have coordinates (without them jerking)

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
unregistered
Newbie
Posts: 17
Joined: Tue Apr 21, 2020 5:18 am
Contact:

Zooming ATL displayables that have coordinates (without them jerking)

#1 Post by unregistered »

I try to zoom an animation out of several frames, created in ATL. However, the animation jerks out as soon as it zooms. This is a capture directly from the situation in Renpy:

Image


The animation is created out of frames that are cropped and have positions. Like this:

Code: Select all

image animation:
   image1.png
   pos (x1,y1)
   0.2
   image2.png
   pos (x2,y3)
   0.2
   ...
   
etc.


So, I think I need to create a fixed border around that animation so it can be zoomed correctly and currently it's unable to zoom because zoom doesn't consider the right new position coordinates. I could probably do this with Composite and the coordinates, but this would mean I would need to do it with every single frame.

I looked at the docs, but wasn't really able to find a suitable solution that is more elegant. Can anybody point me towards the right track? Thanks! :D

(I know that I could ask my graphics artist to create the animation frames in equal sizes, but that's not how our visual pipeline works, because all images are cropped by a script and the positions written into renpy code automatically and it would be a hassle to change the whole working pipeline just for this.).

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

Re: Zooming ATL displayables that have coordinates (without them jerking)

#2 Post by Ocelot »

I see four three immideate solution.

0) Just make all images the same size. Add another step into your pipeline which will resize images to the correct size. You mentioned that it is too much of a hassle, but it is the best solution perfomance and support-wise

1) Place all images into a Fixed with fixed size and properly position each image withing each Fixed. Then use those Fixed's in your animations (this is technically the same thing as (0), but bone programmatically on RenPy side). Composite is the most friendly way to create such containers:

Code: Select all

 image animation_frame1 = Composite(
    (300, 600), # total size of image
    (5, 0), "frame1.png" # first frame is positioned five pixels to the right of the whole image boundary
)

 image animation_frame1 = Composite(
    (300, 600), # total size of image
    (0, 30), "frame2.png" # second frame is positioned 30 pixels lower than top of the image
)
2) Use *anchor properties. Anchor is the point on the image which is where you "grab" it to place on pos, which is point on screen. This is why you have problems: screen doesn't shrink together with your image when you zoom it. Instead of setting position manually, change anchors so if all images would have their anchors put on top of each other, you will have all images in correct places:

Code: Select all

image animation:
    anchor (-5, 0) # the same as with previous example: make image be 5 pixels to the right of position
    "frame1.png"
    anchor (0, -30)
    "frame2.png"
3) Put your image in a fixed-size fixed in a screen and apply zoom to that fixed alone.

Of course, all those solutions will require you to recalculate all offsets and all numbers will change, because you will switch from absolute positioning on screen to the relative positioning within some canvas and then placing those canvas on screen.
< < insert Rick Cook quote here > >

unregistered
Newbie
Posts: 17
Joined: Tue Apr 21, 2020 5:18 am
Contact:

Re: Zooming ATL displayables that have coordinates (without them jerking)

#3 Post by unregistered »

Thanks for the many ideas! It helped already.

I think what I will do is to go for solution 1 and include them into our pipeline. My script know the coordinates and the size I need so it's actually quite easy to parse it and just throw out an out-generated .rpy file with Composites and then use these composite displayables for ATL and zoom. It's also a little better maintaing-wise for me, because I then have displayables with same sizes that I can animate just like you would do.

I'll see if this is perfromance-wise an issue - but for the time being it's probably the easiest solution. If it's not, I will probably go for solution 0 and will either ask my graphics artist to make all animations same size or use imagemagick to do it.

Post Reply

Who is online

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