We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Pages: 1 2 3 
Timeline (Read 20316 times)
Timeline
Apr 26th, 2009, 7:48pm
 
Hi, I'm a computer science student at UCLA.  During this academic year, I've been working on a research project (advised by Casey) that will ultimately result in a Processing tool and library.  I've got a preview version of the tool/library that's ready enough for the public to start using, and I thought that this forum would be the best way to get the word out.  


What is the timeline?

The timeline is a combination of a timeline tool for the Processing Development Environment that allows you to draw curves representing variables over time, and a timeline library that allows you to use these variables in your sketches.

The timeline tool looks like a traditional timeline that you might see in multimedia applications like Flash, Reason, Final Cut Pro, etc.  In all of these applications, the timeline has a very specific purpose.  In this Processing timeline, you can use the timeline to control whatever you want in your code.

The timeline tool uses Bézier splines to represent each variable.  These splines give you a lot of control, and you might already be used to this kind of drawing tool (e.g., the pen tool in Illustrator/Photoshop/Flash).  However, the Bézier splines in the timeline tool have a restriction: they must never backtrack.  Since we are plotting time vs. value, we have to be careful to never have more than one value for a given time.

The timeline library works by loading a data file created by the timeline tool. Using the library allows you to retrieve the value of the timeline variables at the current moment in time.  


Installation instructions

The library and tool are included in this zip file:

www.drifkin.net/timeline/timeline-a001.zip

Unzip the file and then place "TimelineLibrary" within the "libraries" folder of your Processing sketchbook and "TimelineTool" within the "tools" folder of your Processing sketchbook.  Create the "libraries" and "tools" folders if they don't already exist.  

The location of the Processing sketchbook is described on the Processing.org libraries reference page: "To find the Processing sketchbook location on your computer, open the Preferences window from the Processing application and look for the "Sketchbook location" item at the top."


Timeline tool instructions

Launch PDE and go to "Tools" -> "Timeline".  Press the "Add" button in the bottom left corner to add a new variable track.  Press the "Rename" button on the new track and give the variable a better name.  

The current mode you're in is indicated by the selected button at the top of the screen.  There are currently two modes:

Draw points — Click and drag anywhere to the right of the spline to create a new point.  Click on the curve to insert a point on the curve, without changing the shape of the curve.

Move points — Click and drag points to change their location.  While dragging a tangent (the circular handles), hold down the "alt" key to adjust only that tangent.  With an anchor (the square handles) selected, hit "backspace" to remove that anchor and its corresponding tangents.

The y-axis will auto-pan and auto-zoom to keep everything on screen.  To pan along the time-axis, grab and drag the time ruler at the top.  To zoom along the time-axis, adjust the zoom slider at the bottom of the window.

Hit the "Save" button to save to a file called "timeline-data.txt" in your sketch folder.  Hitting the "Load" button will load from this file if it exists, discarding any changes you've made since your last save.  Don't forget to save — the data file is the means of communication between the tool and library.


Timeline library instructions

The library is simple.  In PDE, go to "Sketch" -> "Import Library..." -> "TimelineLibrary".  This will add the following import code to the top of your sketch:

Code:
import timeline.*; 



You'll want to make a global Timeline variable:

Code:
Timeline timeline; 



Now in your setup code, you need to create the Timeline object.  Pass it "this" so it knows about your sketch.

Code:

void setup() {
 ...

 timeline = new Timeline(this);

 ...
}


There's an optional second parameter in the constructor for sketches that do not run in realtime (i.e., the sketch is going to be rendered into a movie).  The parameter is an integer that specifies the frame rate of the movie.  When this parameter is specified, the library determines the current time (that corresponds to the time-axis in the timeline tool) based on the current frame, instead of the time elapsed.

Now in your drawing code, you can retrieve the current value of a variable using the getValue() method.  For example, you may have created a variable in the timeline tool called "brightness".  You retrieve the value by passing getValue() the name of the variable:

Code:

void draw() {
 ...

 float value = timeline.getValue("brightness");

 ...
}


That's it.  Now you can do just about anything with the retrieved value.  Of course, you can create multiple variable tracks in the timeline tool and use getValue() multiple times to get the value of each variable.



(Continued in the next post...)
Re: Timeline
Reply #1 - Apr 26th, 2009, 7:49pm
 
Example

Here's a pretty boring, yet illustrative, example:

Code:

import timeline.*;
Timeline timeline;

void setup() {
 timeline = new Timeline(this);
 stroke(255, 0, 255);
}

void draw() {
 background(0);
 float pointHeightValue = timeline.getValue("pointHeight");
 point(width/2.0f, pointHeightValue);
}


In the timeline tool, create a new variable track using the "Add" button and rename it to "pointHeight".  Now draw a curve that represents the the y-location of the point drawn in the draw() method.  Try to keep the curve between the values 0 and 400 (the height of the sketch).  Press the "Save" button.

Now run the sketch.  A magenta point will be drawn in the middle of the screen, with the height following the curve you drew.  You are now ready to come up with your own, much more exciting examples.


Known Issues

There are a bunch of optimizations I'm going to do in the near future that will improve performance significantly (mainly for the tool).  The way I'm handling some of the GUI elements will probably change.  OS X in particular has trouble with scrolling many heavyweight GUI components (crazy flickering).  Right now each variable lane is its own PApplet, which is probably not the most efficient approach.

I haven't tested a recent version of this on a Linux yet.  I'll be doing that soon.  I suspect some of the UI elements might be off by a few pixels.


Coming Soon

The next major feature I'll be adding is the ability to remove tangents by dragging them to their anchor point.  A corresponding mode will be added that will let you revive these removed tangents.



I'm looking for any feedback: what do you like, what do you not like, feature suggestions, etc.  I'm particularly interested in what people will end up creating using the timeline.  The timeline is still very much under development, and feedback I get in this forum will influence its future.

A site including more thorough examples and documentation (and maybe even screenshots) is forthcoming.  I just wanted to release this as soon as possible to start getting feedback.

Thank you,
Devon Rifkin
Re: Timeline
Reply #2 - Apr 27th, 2009, 2:34am
 
Very interesting, JavaFX looses some of its advantages... Wink Actually, it doesn't even have a graphical tool, so you are way ahead!

I must remember to go back here and test that!
Re: Timeline
Reply #3 - Apr 27th, 2009, 3:12am
 
an early reply jsut to confirm my interest to your tool.

Not tested yet but be sure I will and let you know my comments.

Thanks for sharing

Paul
Re: Timeline
Reply #4 - Apr 27th, 2009, 7:51am
 
Hi Devon,

I tried your lib and unfortunately doesn't work.
Lib is ok but the tool isn't recognize.

I put the TimelineTool folder in a tools subfolder but nothing appears in the Tools menu.

Processing version : 1.0.3
OS : MAC OS X 10.5.6

Also, I did first put the TimelineLibrary into libraries subfolder but didn't work until I put the jar in a code subfolder.

What did I not sunderstand ?


Paul

ps: does some doc exist ?
Re: Timeline
Reply #5 - Apr 27th, 2009, 3:11pm
 
Hello Devon,

I just tried your lib and it seems to work for me although i don't have, at this stage, made any serious attempts beyond simple tests to get a feel of what it'd bring.

@paul_pom: i have the same configuration than you and it works for me. Have you set it up as follows:
  • <SKETCHBOOK>
  •  <SKETCHBOOK>/tools/
  •  <SKETCHBOOK>/tools/TimelineTool
  •  <SKETCHBOOK>/tools/TimelineTool/src
  •  <SKETCHBOOK>/tools/TimelineTool/tool
Re: Timeline
Reply #6 - Apr 27th, 2009, 3:26pm
 
paul_pom wrote on Apr 27th, 2009, 7:51am:
Hi Devon,

I tried your lib and unfortunately doesn't work.
Lib is ok but the tool isn't recognize.

I put the TimelineTool folder in a tools subfolder but nothing appears in the Tools menu.

Processing version : 1.0.3
OS : MAC OS X 10.5.6

Also, I did first put the TimelineLibrary into libraries subfolder but didn't work until I put the jar in a code subfolder.

What did I not sunderstand


Paul

ps: does some doc exist


Hi Paul,

What exactly did you have to do to get the library to work

The directory structure that tanepierre shows above is correct.  More specifically, on OS X (assuming the default location for the Sketchbook) the tool jar file should be located at:

/Users/<your_username>/Documents/Processing/tools/TimelineTool/tool/TimelineTool
.jar

If this still doesn't work for you, let me know so that we can try to figure out what's going on.

(by the way, more documentation is coming — I'm just in the middle of midterm season right now)

Re: Timeline
Reply #7 - Apr 28th, 2009, 1:10am
 
thanks guys,

Work for me too.
I thought sketchbook was sketchfolder... Sorry.

I am now on my way to test this.

All good for your midterm session, I will discover your work deeply through your code.

I'll let you know my comments.

regards,

Paul
Re: Timeline
Reply #8 - May 7th, 2009, 11:16pm
 
thats great. There are so many new possibilities of animating coming up.
Is there a way to loop it somehow, or start it at a given point?
for example, onMouseOver  or any other "if(XX==YY)-events" ?

Great work so far!
Re: Timeline
Reply #9 - May 7th, 2009, 11:45pm
 
i played arround with it for a while. Maybe it wouldbe useful to choose between frames and seconds for the timeline. And the possibility to jump to a given point at the timeline for every single variable. So it would be possible to jump back and forth to any given point to start or end some animations depending on different events.
I mentioned the ability to loop. If it is possible it would be nice to not only loop again from the beginning but reverse it and play it backwards.

Just some things that came to my mind. Im really looking forward to work with it. Its a great tool.
Re: Timeline
Reply #10 - May 11th, 2009, 3:38am
 
Hi Cedric, thank you for the feedback and ideas.

I'm glad you think looping is a good idea because that is a feature that I intend to add.  I'm going to have support for looping by going to the beginning after reaching the end, as well as going back and forth between the beginning and end repeatedly.  Another playback method will be "random", where it will randomly choose a time value between the (not yet existing) beginning and end markers.

I'm a bit undecided about using frames as the ruler units.  Could you give me a few use cases where you think frames would be better than time units?  I originally was going to have frames as an option, but realized that having support for specifying the framerate in the library made this feature not as necessary.

As far as resetting the timeline, would something like this be useful?

Code:
// resets the current time for the variable to the beginning
timeline.reset("variable_name_here");


Or do you think more control is necessary, like this:

Code:
// sets the current time for the variable
// (in this case, 10.5 seconds in)
timeline.setTime("variable_name_here", 10.5);


Or maybe even less control:

Code:
// resets all variables to the beginning
timeline.reset();

Re: Timeline
Reply #11 - May 11th, 2009, 4:27am
 
d.rifkin wrote on May 11th, 2009, 3:38am:
I'm a bit undecided about using frames as the ruler units.

Me too. I started to use them in a recent program, and found it was unreliable, because the frame rate can drop a lot when display is CPU heavy.

Quote:
As far as resetting the timeline, would something like this be useful
- // resets the current time for the variable to the beginning
- // sets the current time for the variable
- // resets all variables to the beginning

For what it is worth, JavaFX's Timeline allows to set the time arbitrarily on any point of the time line.
It also has a playFromStart(), kind of shortcut for tl.time = 0s; tl.play(); I think. Note you can have several independent timelines.
Not sure how it can applies to your library, I haven't, alas, found time to look at it closer.
Re: Timeline
Reply #12 - May 26th, 2009, 7:48pm
 
I'll be releasing a new version later today that will have support for setting the current time of a specific timeline variable.

It'll work like the example I gave earlier:

Code:
// sets the current time for the variable
// (in this case, 10.5 seconds in)
timeline.setTime("variable_name_here", 10.5);


Adding another method that takes a string specifying which variable made me think about the interface again.  Does anyone think it would be better to have an object for each timeline variable?  It might look something like this:

Code:
import timeline.*;
TimelineVariable var1, var2, var3;

void setup() {
   var1 = new TimelineVariable(this, "Variable 1");    
   var2 = new TimelineVariable(this, "Variable 2");
   var3 = new TimelineVariable(this, "Variable 3");
}

void draw() {
   System.out.println("Variable 1 is " + var1.getValue());
   System.out.println("Variable 2 is " + var2.getValue());
   System.out.println("Variable 3 is " + var3.getValue());
}

void mousePressed() {
   // reset Variable 1 if mouse is pressed
   var1.setTime(0.0);
}
Re: Timeline
Reply #13 - May 27th, 2009, 2:27am
 
The website for the timeline is now up at http://www.drifkin.net/timeline

On the website you'll find a new release of the timeline, version a002.  It has a few new features:

  • There are navigation buttons on either side of the ruler that you can click to navigate along the time-axis.  The ability to click and drag the ruler to navigate remains.
  • If you move tangents very close to their anchor, they disappear.  This allows you to draw sharp edges.  To recreate these tangents, use the new "Create Tangents" mode.  Once in this mode, click and drag on an anchor to recreate its tangents.
  • You can now set the current time of a particular variable.  The interface for doing so is in the previous post.  I have also provided an example sketch in the library folder called "setTime".  It shows how you reset an animation (in the example, a mouse click triggers the reset).
Re: Timeline
Reply #14 - May 27th, 2009, 8:25am
 
This is very interesting, would be great to see it in the core.  Congrats on your work!   Sequencing is key to furthering the possibilities of the platform.
Pages: 1 2 3