bio photo

Well, I'm currently rewriting the old Nifty Introduction Demonstration that somehow didn't survive my last blog server switch :( It was posted right here</a> but the jnlp disappear. The demo explained some basic concepts of Nifty and it was written in Nifty :) I'm rewritting it now to update it to the current Nifty Standards.

In the process I just want a moving Nifty GUI Logo like this one

<img class="alignnone size-medium wp-image-109" title="tutorial-intro" src="http://nifty-gui.lessvoid.com/wp-content/2009/10/tutorial-intro.gif" alt="" width="128" height="96" /></a>

So the logo should resize while fading in and keep on resizing while fading out.


My first try was this xml (only the resizing part is shown with the "imageSize" effect attached to "onStartScreen"):

<onStartScreen name="imageSize" startSize="0.7" endSize="1.0" time="600" neverStopRendering="true" />
<onStartScreen name="imageSize" startSize="1.0" endSize="1.3" time="600" neverStopRendering="true" startDelay="600" />
</pre>

Which was reasonable but doesn't work. It doesn't work because effects with a startDelay are in fact already active. In this case the second onStartScreen imageSize effect overwrites the first one with it's intial startSize of 1.0 for the time the startDelay is active. Which, yeah, makes sense for most effects but sucks in this case.

What I'd really want to write is this instead:


<value time="0" value="0.7" />
<value time="600" value="1.0" />
<value time="1200" value="1.3" />
</onStartScreen></pre>

Well, and now you can actually write it like this! :D

What this does is performing linear interpolation for of the given values. In the example above the value for the imageSize effect starts with 0.7 and changes to 1.0 over a time of 600ms. After that it continues to be interpolated from 1.0 to 1.3 for the next 600ms. When value tags are present they will overwrite the length parameter of the effect. So in the example the imageSize effect will last for 1200ms.

I've just commited this to svn. It is still work in progress and is therefore only available for the "imageSize" and the "fade" effect. I'm currently thinking about extending it to other effects where it is appropriate. I'm also considering to not only interpolate float values but to make it more general and the actual values are effect specific, so that you could interpolate color values for instance.

void