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

Saturday, 13 November 2010

Spheres

Here is an idea I had for creating an eisencript (yet to be realized), that is based on a processing sketch by Ira Greenberg from "Creative Coding and Computational Art". I also used the sketch to test using ffmpeg to encode the video (results in need of some refinement but it is damn quick).


Spheres from monkstone on Vimeo.

   1 import processing.opengl.*;
   2 
   3 // Interlocking Sphere Rings
   4 float radius = 150.0;
   5 int segments = 12;
   6 float sphereSize = 42;
   7 void setup() {
   8   size(640, 480, OPENGL);
   9   setupOpenGL();
  10   noStroke();
  11   fill(255);
  12   sphereDetail(24);
  13 }
  14 
  15 void draw() {
  16   background(0);
  17   lights();
  18   translate(width/2, height/2);
  19   rotateY(frameCount*PI/100);
  20   rotateX(frameCount*PI/92);
  21   float x, y, z;
  22   for(int i=0; i<3; i++) {
  23     float ang = 0;
  24     for(int j=0; j<segments; j++) {
  25       pushMatrix();
  26       if (i==0) {
  27         x = cos(ang)*radius;
  28         y = sin(ang)*radius;
  29         z=0;
  30       }
  31       else if (i==1) {
  32         x = cos(ang)*radius;
  33         z = sin(ang)*radius;
  34         y=0;
  35       }
  36       else {
  37         y = cos(ang)*radius;
  38         z = sin(ang)*radius;
  39         x=0;
  40       }
  41       translate(x, y, z);
  42       sphere(sphereSize);
  43       popMatrix();
  44       ang+=TWO_PI/segments;
  45     }
  46   }
  47   saveFrame("img####.jpg");
  48 }
  49 
  50 void setupOpenGL(){
  51   hint(DISABLE_OPENGL_ERROR_REPORT);
  52   hint(ENABLE_OPENGL_4X_SMOOTH);
  53 }

Creating the movie using ffmpeg:-

ffmpeg -f image2 -i img0%3d.jpg movie.mp4

.....................

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