Transformation Language Design

In this forum we discuss the future of Ren'Py, both bug fixes and longer-term development. Pre-releases are announced and discussed here.
Post Reply
Message
Author
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:

Transformation Language Design

#1 Post by PyTom »

So, I'm working on the transformation language that will be part of Ren'Py, probably starting with the next release. The idea of the transformation language is to provide a convenient way to specify the placement, rotation, scaling, and opacity of images. It will also provide a way to define animations. The idea is that this will become the preferred way to specify aspects of display that vary with time.

Let's see the most trivial transform:

Code: Select all

transform right:
    xalign 1.0
This is the equivalent of the current "right" position, displaying an image on the right of the screen.

This is pretty boring, so let's take a look at a transform that starts the image on the left, moves it to the right, then back to the left:

Code: Select all

transform bounce_once:
    0: xalign 0.0
    2: xalign 1.0
    4: xalign 0.0
We now have multiple lines. Each gives a time, and a position. So at 0 seconds it's at the left, at 2 seconds it's at the right, and then at 4 seconds its at the left again. By default, the values are linearly interpolated, but that can be changed, using (for example):

Code: Select all

transform bounce_once_ease:
    0: xalign 0.0
    2: xalign ease(1.0)
    4: xalign ease(0.0)
Which would use the ease function to do the interpolation.

Giving the repeat statement causes the current block of code to repeat from 0.

Code: Select all

transform bounce:
    0: xalign 0.0
    2: xalign 1.0
    4: repeat
By nesting statements, the amount of time the repeat is for can be controlled:

Code: Select all

transform bounce_three_times:
    0: 
         0: xalign 0.0
         2: xalign 1.0
         4: repeat
    12: 
         xalign 0.0
By separating them with commas, one can include multiple properties on a single line. (Note: I need a better word than property here, as properties is used by the style system.)

Code: Select all

transform v_shape:
    0: xalign 0.0, yalign 0.0
    1: xalign 0.5, yalign 1.0
    2: xalign 1.0, yalign 0.0
Other properties include "rotate", "scale", and "alpha". The following spins its child forever:

Code: Select all

transform spin:
    0.0: rotate 0
    4.5: rotate 360, repeat
While this scales it to full size:

Code: Select all

transform scale:
    0.0: scale 0
    1.0: scale 1
The "parallel" statement lets you run both transforms at the same time. So the following will scale the child while spinning it, and then keep it spinning even after the scaling is done.

Code: Select all

transform scale_and_spin:
    parallel:
        0.0: rotate 0
        4.5: rotate 360, repeat
    parallel:
        0.0: scale 0
        1.0: scale 1

I'm not sure about the syntax, but I'd also like for it to be possible to define an animation using this mechanism. So one could probably do:

Code: Select all

image eileen anim: 
     0: "eileen_happy.png"
     1: "eileen_vhappy.png"
     2: repeat
Of course, this would compose with other transforms.

I have some other ideas (like the ability to respond to events such as idle and hover), but these are the basics, and I thought I'd run them by the community before I start the implementation work. Any comments? Suggestions?
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

KimiYoriBaka
Miko-Class Veteran
Posts: 636
Joined: Thu May 14, 2009 8:15 pm
Projects: Castle of Arhannia
Contact:

Re: Transformation Language Design

#2 Post by KimiYoriBaka »

I haven't done anything with transformations so I don't know if this would be obvious or not, but when would the repeat statement end if there's nothing in the transformation after it? Would it just wait until the image is told to hide?
"I know that I have blood on me. I know because I see it here. the things i've done are not to be condoned nor praised."
-Aiya, daughter of Raik II
Castle of Arhannia- slowly progressing. script 60% art 5% music 0% minigame 90%

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:

Re: Transformation Language Design

#3 Post by PyTom »

Yes, unless there's something to end it, it would go on forever. (Until hidden.)
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

delta
Epitome of Generic
Posts: 525
Joined: Sat Dec 22, 2007 12:59 pm
Projects: yes
Contact:

Re: Transformation Language Design

#4 Post by delta »

I'm not sure whether I like a new kind of baseline block in addition to init and label blocks.
The rest is left as an exercise for the reader.

EvilDragon
Veteran
Posts: 284
Joined: Fri Dec 28, 2007 5:47 am
Location: Where the Dragons rule!
Contact:

Re: Transformation Language Design

#5 Post by EvilDragon »

This is a very good idea, opening up a LOT of possibilities. Syntax seems fairly easy to get a grasp on, too.

Will something similar be available for text? (Y'know, showing several lines at once in NVL mode for example, with various text effects here and there, etc.)
Angels of paradise, angels of sacrifice
Please let me be under your wings...

delta
Epitome of Generic
Posts: 525
Joined: Sat Dec 22, 2007 12:59 pm
Projects: yes
Contact:

Re: Transformation Language Design

#6 Post by delta »

Well, Ren'Py does not offer a lot of text effects anyway, there isn't even a property for kerning bonuses. If there was, it would be a neat (but not crucial) effect to adjust it over time.
The rest is left as an exercise for the reader.

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:

Re: Transformation Language Design

#7 Post by PyTom »

http://www.renpy.org/wiki/renpy/doc/ref ... m_Language

I've posted up a specification for how I plan to implement the new animation and transformation language. I think I've simplified it a bit compared to what I have above. Some examples.

An animation:

Code: Select all

image eileen anime:
    "eileen_happy.png", 1.0
    "eileen_vhappy.png", 1.0
    repeat
Move from the left side of the screen, to the right side of the screen, and then back to the left.

Code: Select all

transform left_right_left:
    xalign 0.0
    pause 2
    xalign linear 1.0
    pause 2
    xalign linear 0.0
Grow to 120% of the usual size when hovered, shrink back when unhovered.

Code: Select all

transform expando:
     event hover:
          pause .5
          zoom linear 1.2
     event idle:
          pause .5
          zoom linear 1.0
The idea is that the ATL will provide a high-level way of expressing things that are currently done by Animation, TransformAnimation, SMAnimation, Zoom, FactorZoom, RotoZoom, Move, Pan, Transform, and probably a bunch of other functions I can't remember offhand.
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

chronoluminaire
Eileen-Class Veteran
Posts: 1153
Joined: Mon Jul 07, 2003 4:57 pm
Completed: Elven Relations, Cloud Fairy, When I Rule The World
Tumblr: alextfish
Skype: alextfish
Location: Cambridge, UK
Contact:

Re: Transformation Language Design

#8 Post by chronoluminaire »

Cool. That does look... "Ren'Py-ish". As in, it's a very simple, punctuation-free way of expressing some very powerful and versatile concepts.
I released 3 VNs, many moons ago: Elven Relations (IntRenAiMo 2007), When I Rule The World (NaNoRenO 2005), and Cloud Fairy (the Cute Light & Fluffy Project, 2009).
More recently I designed the board game Steam Works (published in 2015), available from a local gaming store near you!

Spiky Caterpillar
Veteran
Posts: 253
Joined: Fri Nov 14, 2008 7:59 pm
Completed: Lots.
Projects: Black Closet
Organization: Slipshod
Location: Behind you.
Contact:

Re: Transformation Language Design

#9 Post by Spiky Caterpillar »

Ooh. I think that this will be quite cool.

Is 'pause' a pause between transformations, a pause during which transformations take place, or the duration of a transformation? If the lattermost it might be better to call it 'duration'.

In the definition for parallel:
The blocks within a set should be independent of each other, and manipulate different properties. When two blocks change the same property, the result is undefined.
In a likely-to-change-between versions sense, a likely-to-change-between-executions sense, or an exceptionthrowing sense?
(Eying the possibility of epicycle transforms. Even though I don't really need them.)
Nom nom nom nom nom LEAVES.

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:

Re: Transformation Language Design

#10 Post by PyTom »

The pause is a pause during which transitions occur.

For now, if you were to do:

Code: Select all

parallel:
     xalign linear 0.0
     pause 2
     xalign linear 1.0
     pause 2
     repeat
parallel:
     xalign linear 0.0
     pause 1
     xalign linear 1.0
     pause 1
     repeat
The result would be that one of the two blocks (probably the second) would manipulate xalign, and the other one would not. I might eventually look into relaxing this (which would be a change between versions), but probably not in the first version. For many of these, composing two values is a meaningless operation... it's not clear to me that an xalign of 0.0 and an xalign of 1.0 should compose to 0.0, for example.

If someone wants to take it upon themselves to write sensible rules for composing property updates, by all means do so.
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

Counter Arts
Miko-Class Veteran
Posts: 649
Joined: Fri Dec 16, 2005 5:21 pm
Completed: Fading Hearts, Infinite Game Works
Projects: Don't Save the World
Organization: Sakura River
Location: Canada
Contact:

Re: Transformation Language Design

#11 Post by Counter Arts »

Would it be too hard to have both just change the value whenever and the last written one wins? And if the pauses are equal in length and alter the same event just have it undefined or random?

Or are you compiling it so it can execute fast or doing something else to keep maintaining it easy?

But MAN this is going to really rock.
Fading Hearts is RELEASED
http://www.sakurariver.ca

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:

Re: Transformation Language Design

#12 Post by PyTom »

That's how I plan to do it. But I want to reserve the right to alter this in the future, so for now it's undefined.
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

Counter Arts
Miko-Class Veteran
Posts: 649
Joined: Fri Dec 16, 2005 5:21 pm
Completed: Fading Hearts, Infinite Game Works
Projects: Don't Save the World
Organization: Sakura River
Location: Canada
Contact:

Re: Transformation Language Design

#13 Post by Counter Arts »

Okay... I thought so.

If a position transformation is in progress with ease or linear and gets interrupted by an event, the "from" coordinates are going to be from where the displayable currently is right? And not the coordinates from the end of the first transformation?
Fading Hearts is RELEASED
http://www.sakurariver.ca

luminarious
Veteran
Posts: 353
Joined: Thu May 01, 2008 1:12 pm
Projects: Winter, winter
Location: Estonia
Contact:

Re: Transformation Language Design

#14 Post by luminarious »

PyTom wrote:

Code: Select all

transform bounce_once:
    0: xalign 0.0
    2: xalign 1.0
    4: xalign 0.0
We now have multiple lines. Each gives a time, and a position. So at 0 seconds it's at the left, at 2 seconds it's at the right, and then at 4 seconds its at the left again. By default, the values are linearly interpolated, but that can be changed
This syntax is really easy on the eyes, being in turn quick to understand, especially if the sequence is longer. I'm all for 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:

Re: Transformation Language Design

#15 Post by PyTom »

I've actually bounced off that syntax a bit. The new syntax for the same thing would be:

Code: Select all

transform bounce_once:
    time 0.0, xalign linear 0.0
    time 1.0, xalign 1.0
    time 2.0, xalign 0.0
You can also use pause, which can be written as:

Code: Select all

transform bounce_once:
    xalign linear 0.0
    pause 1.0, xalign 1.0
    pause 1.0, xalign 0.0
Since a number is a pause, this can also be:

Code: Select all

transform bounce_once:
    xalign linear 0.0, 1.0, xalign 1.0, 1.0, xalign 0.0
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

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]