How to change order of transformations? [Solved]

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
Dawn
Newbie
Posts: 14
Joined: Sun Apr 30, 2017 3:49 am
Projects: Nephilim — Revelation
Contact:

How to change order of transformations? [Solved]

#1 Post by Dawn »

As explained in documentation, the transformation properties are applied in the following order:
  1. tile
  2. crop, corner1, corner2,
  3. size,
  4. zoom, xzoom, yzoom,
  5. pan,
  6. rotate,
  7. position properties
I would like to do rotation before resizing (to have a rotating ellipse).

Code: Select all

    
    transform rotate_object:
        size(200,400)
        rotate 0
        linear 8 rotate 360
        repeat
How can I do it ? Have I to update renpy code ?
Last edited by Dawn on Sat Jun 24, 2017 5:03 am, edited 1 time in total.

User avatar
shakeyss
Newbie
Posts: 17
Joined: Sun Jun 11, 2017 10:58 am
Projects: Moonlit Tears
Organization: Digilikha Studios
Soundcloud: shakeyss
itch: digilikha
Location: Philippines
Contact:

Re: How to change order of transformations?

#2 Post by shakeyss »

I also want to know this too, for future reference. I hope someone will answer this.

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: How to change order of transformations?

#3 Post by trooper6 »

Just create your own transform that first rotates, then resizes.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
Dawn
Newbie
Posts: 14
Joined: Sun Apr 30, 2017 3:49 am
Projects: Nephilim — Revelation
Contact:

Re: How to change order of transformations?

#4 Post by Dawn »

How do you do it?

Before asking, I tried to do it and the result does not change.

Code: Select all

    transform rotate_object:
        rotate 0
        linear 8 rotate 360
        size(200,400)
        repeat
Last edited by Dawn on Mon Jun 19, 2017 11:50 am, edited 1 time in total.

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: How to change order of transformations?

#5 Post by Divona »

Let me try to explains the code here:

Code: Select all

## Create transform.
transform rotate_object:

    ## Begin the transform
    ## Reset sprite rotation to zero.
    rotate 0

    ## When the line of code above finished set sprite rotation to zero
    ## Rotate sprite around 360 degrees in 8 seconds.
    linear 8.0 rotate 360

    ## When the rotation above is finished
    ## Set sprite size to 200 width and 400 height.
    size (200, 400)

    ## When the line above is finished set the size of the sprite
    ## Repeat the transform code from the top.
    repeat
What is the result that you expected?
Completed:
Image

User avatar
Dawn
Newbie
Posts: 14
Joined: Sun Apr 30, 2017 3:49 am
Projects: Nephilim — Revelation
Contact:

Re: How to change order of transformations?

#6 Post by Dawn »

No I'm sorry, I'm not fluent in english. I tried to explain it to my husband and he didn't understand at the beginning. If in french it's difficult to explain... Sorry. My bad ! :) Let's try to be more "clear"

So... Ok... Wait ! I found an example, more explicit.

I have a circle. In the bottom of that circle, I have a dot, like a planet. In some other language, if I do an animated rotation and a resize during this rotation, I obtain a rotating ellipsis, like a planet turning around the sun.

Here is my image:
Image
If i remove the animation, here is what renpy is calculating:
Image
But if the rotation was calculated before the resize, I should have:
Image

You can do it on Gimp :
1 - Create a circle,
2 - Do a rotation of 45°
3 - do a resize

The result is different if you do a resize and after that a rotation of 45°
1 - Create a circle,
2 - do a resize
3 - Do a rotation of 45°


Here is the full code of my attempt (similar transformation works on Flash)

Code: Select all

    transform rotate_object:
        size (400,200)
        parallel:
            rotate 0
            linear 8 rotate 360
            repeat
        ## But because rotation is calculated after resize, the north-south stay larger than the east-west. 
        ## What I want is that the two centers of ellipsis doesn't move, I height and width don't change and your eye think that N and S are rotating on an elliptic line.
        parallel:
            linear 8 size (400,200)
            repeat
Because of the documentation quoted on my first message, I think this "bug" is "normal". Tom is declaring in doc that "for each frame of animation", rotation is calculated AFTER resizing. I tried to inspect atl source code, but it is too complex for me.

Here is the first frames of what I want:
ImageImageImage

User avatar
PyTom
Ren'Py Creator
Posts: 16093
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:

Re: How to change order of transformations?

#7 Post by PyTom »

I don't have time to check it, but you can probably make this work with a pair of transforms:

Code: Select all

transform rotate:
            rotate 0
            linear 8 rotate 360
            repeat

transform resize:
     size (400, 200)

show compass at rotate, resize

Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
Dawn
Newbie
Posts: 14
Joined: Sun Apr 30, 2017 3:49 am
Projects: Nephilim — Revelation
Contact:

Re: How to change order of transformations?

#8 Post by Dawn »

Thanks a lot Tom ! It works exactly like I want. I didn't know that I could combine transformations.

Code: Select all

## transform.rpy file
    transform rotate:
        rotate 0
        linear 8 rotate 360
        repeat

    transform resize:
        size (400, 200) 

Code: Select all

##screens.rpy file

screen main_menu():

    ## This ensures that any other menu screen is replaced.
    tag menu

    style_prefix "main_menu"

    add gui.main_menu_background

    ## This empty frame darkens the main menu.
    frame:        
        pass
        
        add main_pentacle at rotate, resize:
            pos (136, 535)

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]