Layered image actual size and anchor?

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
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Layered image actual size and anchor?

#1 Post by xavimat »

Ok. I have a weird question. How are total size and anchor position of a layeredimage calculated?
This code:

Code: Select all

transform spining:
    rotate 0
    linear 2 rotate 360
    repeat
layeredimage things:
    always:
        align (0.5, 0.5)
        rotate 12
        "red"
    always:
        align (0.5, 0.5)
        "green"
    always:
        at spining
        align (0.5, 0.5)
        "blue"
label start:
    show things at truecenter
    pause
    return
Gives me this result (it's clearly not at truecenter):
screenshot0003.png
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

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

Re: Layered image actual size and anchor?

#2 Post by Imperf3kt »

I believe truecenter aligns to the center of the window, not the sprite.
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
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Layered image actual size and anchor?

#3 Post by xavimat »

Internally, renpy defines truecenter this way:

Code: Select all

    transform truecenter:
        xpos 0.5 xanchor 0.5 ypos 0.5 yanchor 0.5
So both position and anchor are on the center of the screen.
The image I've attached is actually at truecenter. The problem are the calculations of the size of the layeredimage.
Layeredimage creates a fixed with xfit, and yfit.
It calculates sizes of the layers. If there is a transform it wraps that layer, if the transform is a rotation, it needs to calculate a larger space for the rotation to fit.
Tom on discord said that probably xfit, yfit and rotations didn't work ok together.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Layered image actual size and anchor?

#4 Post by Remix »

You could tell the transform to pre-pad the canvas for rotation (making a square of hypotenuse by hypotenuse)

Code: Select all

transform spining:
    rotate_pad True
    rotate 0
    linear 2 rotate 360
    repeat
Maybe with transform__anchor True as well
Frameworks & Scriptlets:

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], haitai