Recently I've been looking at Povray, pyprocessing, and cfdg (version 3.0) as tools for creating digital images. I have branched two separate blogs where I mainly explore jruby + processing and processing.py

Friday, 19 November 2010

StructureSynth javascript interface

Here is the the javascript that I wrote to test my idea for animating my tic tac toe (Jack wins!!). This is the chicken route, where I first create 9 eisenscripts for the following story board:-

  1. Empty frame Frame00.es
  2. One Jack (cross) Frame01.es
  3. One Jack and One Sphere (nought) Frame02.es
  4. Two Jacks and One Sphere Frame03.es
  5. Etc

Of course with cut and paste this is very easy (in fact easiest way of working is probably to create the "final frame" then work back commenting out the last step until you are left with the empty frame.

   1 #javascript
   2 
   3 function pad(num) {
   4   number = num + '';                        // convert integer to string
   5   while (number.length < 2) {
   6     number = "0" + number;    
   7   }
   8   return number;
   9 }
  10 
  11 for (i = 0; i <= 8; i++){
  12   name = "/home/tux/es/Frame" + pad(i);    // pad to match eisen script names
  13   Builder.load(name + ".es");
  14   Builder.reset();  
  15   Builder.setSize(0, 480);
  16   Builder.build();
  17   image = name + "00.png" // pad to allow for duplicate frames
  18   Builder.raytraceToFile(image, true);
  19 }
  20 

Here is the result where I padded the sketch with duplicate frames (1 .. 99), (101 - 199), etc...
It is still all over a bit too quickly but at least it works.
I used ffmpeg to stitch together frames as a movie:-

ffmpeg -f image2 -i Frame0%3d.png movie.mp4



3D tic tac toe (structuresynth 1.5) from monkstone on Vimeo.

No comments:

Post a Comment

Followers

Blog Archive

About Me

My photo
Pembrokeshire, United Kingdom
I have developed JRubyArt and propane new versions of ruby-processing for JRuby-9.1.5.0 and processing-3.2.2