# Q: visualisation for simple animations (e.g. cel. automata)?

**URL:** <https://www.ruby-forum.com/t/q-visualisation-for-simple-animations-e-g-cel-automata/160437>\
**Category:** Ruby\
**Created:** [February 16, 2009, 1:08pm UTC](https://www.ruby-forum.com/t/q-visualisation-for-simple-animations-e-g-cel-automata/160437 "2009-02-16T13:08:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![diego\_v](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/eb8c5e/32.png) [@diego\_v](https://www.ruby-forum.com/u/diego_v)\
**Post date:** [February 16, 2009, 1:08pm UTC](https://www.ruby-forum.com/t/q-visualisation-for-simple-animations-e-g-cel-automata/160437/1 "2009-02-16T13:08:33Z")

</div>

Hello,  
I would need to create a very simple visualisation for some scientific  
work I am doing. Basically I need to draw points in a 2D graph (and  
specify which colours to use) and each time the user presses the  
spacebar it should move to the next iteration and show (say with a  
line) where everyone is.

What would be the simplest way to go about this?

The first priority is simplicity followed by easy to learn. I don’t  
need either a powerful system nor something that looks pretty (I am  
the only one who’ll use it ^\_^).

thank you in advance

Diego

---

<div class="post-metadata">

**Author:** ![diego\_v](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/eb8c5e/32.png) [@diego\_v](https://www.ruby-forum.com/u/diego_v)\
**Post date:** [February 16, 2009, 1:10pm UTC](https://www.ruby-forum.com/t/q-visualisation-for-simple-animations-e-g-cel-automata/160437/2 "2009-02-16T13:10:54Z")

</div>

Diego V. wrote:

> Hello,  
> I would need to create a very simple visualisation for some scientific  
> work I am doing. Basically I need to draw points in a 2D graph (and  
> specify which colours to use) and each time the user presses the  
> spacebar it should move to the next iteration and show (say with a  
> line) where everyone is.
> 
> What would be the simplest way to go about this?

Any GUI tool with the word “canvas” in it, such as TkCanvas.

---

<div class="post-metadata">

**Author:** ![diego\_v](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/eb8c5e/32.png) [@diego\_v](https://www.ruby-forum.com/u/diego_v)\
**Post date:** [February 16, 2009, 3:42pm UTC](https://www.ruby-forum.com/t/q-visualisation-for-simple-animations-e-g-cel-automata/160437/3 "2009-02-16T15:42:57Z")

</div>

> What would be the simplest way to go about this?

It’ll probably help to use an existing graphing package, as this will  
take care of some of the tricky things for you such as scaling of axis  
limits and plot styles.

Perhaps Gnuplot would work? Depending on which OS you are using it can  
be easy to set up and use from Ruby, but you will have to become a  
little familiar with Gnuplot to be able to control some things. I wrote  
about using Gnuplot with Ruby recently:  
[Fitting curves to data using Ruby and the GNU Scientific Library – Chris Lowis](http://blog.chrislowis.co.uk/2008/12/01/curve-fit-with-ruby-gsl.html)

Hope this helps,

Chris

---

<div class="post-metadata">

**Author:** ![diego\_v](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/eb8c5e/32.png) [@diego\_v](https://www.ruby-forum.com/u/diego_v)\
**Post date:** [February 16, 2009, 6:21pm UTC](https://www.ruby-forum.com/t/q-visualisation-for-simple-animations-e-g-cel-automata/160437/4 "2009-02-16T18:21:01Z")

</div>

Diego V. (in comp.lang.ruby):

> need either a powerful system nor something that looks pretty (I am  
> the only one who’ll use it ^\_^).

The Ming library [http://www.libming.net/](http://www.libming.net/) allows you to generate Flash  
SWF  
files, and there is a Ruby interface package  
[http://mingruby.rubyforge.org/](http://mingruby.rubyforge.org/),  
look here [http://rubyforge.org/news/?group\_id=428](http://rubyforge.org/news/?group_id=428) for latest versions.

The documentation is not really existent, though. You have to look into  
the  
(numerous) example files that come with the package, and look up the  
corresponding functions in the Perl interface doc  
[http://www.libming.net/docs/perl/index.html](http://www.libming.net/docs/perl/index.html).

I just downloaded and installed it and want to use it to learn both Ruby  
and  
Flash.

Joachim

---

<div class="post-metadata">

**Author:** ![diego\_v](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/eb8c5e/32.png) [@diego\_v](https://www.ruby-forum.com/u/diego_v)\
**Post date:** [February 16, 2009, 9:02pm UTC](https://www.ruby-forum.com/t/q-visualisation-for-simple-animations-e-g-cel-automata/160437/5 "2009-02-16T21:02:53Z")

</div>

Phlip wrote:

> Any GUI tool with the word “canvas” in it, such as TkCanvas.  
> TkCanvas is pretty good for 2D animations. I’ve used it in engineering  
> tools (including as a plug-in block for a simulink-based tool for a car  
> company).

I developed a general tool called tkar that runs as a standalone  
process:

[http://path.berkeley.edu/~vjoel/vis/tkar/](http://path.berkeley.edu/~vjoel/vis/tkar/)

It’s based on ruby/tk, but you can feed it data from anywhere, not just  
ruby code. It accepts data from pipes and sockets. Your controlling  
process can decide when to send data, so you would probably handle  
spacebar events on the upstream end of the socket.

It handles basic user interaction fairly well, allowing pan, zoom,  
click, drag-n-drop (the latter two send the commands back out the  
socket, so you can control the effects).

For an overview, see

[http://path.berkeley.edu/~vjoel/vis/tkar/tkar.html](http://path.berkeley.edu/~vjoel/vis/tkar/tkar.html)

and of course the movie

[http://path.berkeley.edu/~vjoel/vis/tkar/movie.gif](http://path.berkeley.edu/~vjoel/vis/tkar/movie.gif)

Full docs–most importantly the data stream protocol and shape defs–are  
in

[http://path.berkeley.edu/~vjoel/vis/tkar/doc/](http://path.berkeley.edu/~vjoel/vis/tkar/doc/)

The program itself is all one file:

[http://path.berkeley.edu/~vjoel/vis/tkar/tkarpi.rb](http://path.berkeley.edu/~vjoel/vis/tkar/tkarpi.rb)

This simulink plugin is quite nice–beats the native simulink 2D  
animation, and is just about as flexible as the simulink plotter block.  
But probably not of interest on this list.

HTH.

---

<div class="post-metadata">

**Author:** ![diego\_v](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/eb8c5e/32.png) [@diego\_v](https://www.ruby-forum.com/u/diego_v)\
**Post date:** [February 16, 2009, 9:40pm UTC](https://www.ruby-forum.com/t/q-visualisation-for-simple-animations-e-g-cel-automata/160437/6 "2009-02-16T21:40:34Z")

</div>

Joel VanderWerf wrote:

> > Any GUI tool with the word “canvas” in it, such as TkCanvas.
> 
> TkCanvas is pretty good for 2D animations.

On second thought…

Writing ruby/tk code directly (rather than over a socket as I suggested)  
is probably a better idea for an animation that’s this simple.

- tkar is especially good if you want to define some complex shapes and  
then move them about, rotate them, change their shape params, etc.

- using ruby/tk directly may be better if you have a grid of colored  
squares and just want to change each square’s color over time. Probably  
there’s even an example you could adapt.

---

<div class="post-metadata">

**Author:** ![diego\_v](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/eb8c5e/32.png) [@diego\_v](https://www.ruby-forum.com/u/diego_v)\
**Post date:** [February 17, 2009, 12:28am UTC](https://www.ruby-forum.com/t/q-visualisation-for-simple-animations-e-g-cel-automata/160437/7 "2009-02-17T00:28:40Z")

</div>

Ruby-processing can be an option.  
[http://wiki.github.com/jashkenas/ruby-processing](http://wiki.github.com/jashkenas/ruby-processing)  
It’s basically a ruby port of processing which is written in java.  
([http://processing.org](http://processing.org)). So you need jruby. Take a look at the  
examples then you’ll see how simple it is to use.

---

<div class="post-metadata">

**Author:** ![diego\_v](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/eb8c5e/32.png) [@diego\_v](https://www.ruby-forum.com/u/diego_v)\
**Post date:** [February 16, 2009, 6:46pm UTC](https://www.ruby-forum.com/t/q-visualisation-for-simple-animations-e-g-cel-automata/160437/8 "2009-02-16T18:46:19Z")

</div>

Diego V. wrote:

> need either a powerful system nor something that looks pretty (I am  
> the only one who’ll use it ^\_^).

Hi,

Have a look at FXRuby, a great and easy to use library.

As a tutorial, you can have a look at this:  
[http://www.attiksystem.ch/index.php/2008/02/21/double-buffering-in-fxrub](http://www.attiksystem.ch/index.php/2008/02/21/double-buffering-in-fxrub)  
y/

Regards,

Philippe
