Processing Software

I just discovered this software simply called Processing. It’s free and I believe open source. It’s actually quite powerful and easy to play around in. 

 

Here’s a few programs I wrote. 

I cant get any of my hosting to co operate, so I’m just going to paste source code. 

 

Audio Circles: 

/**AudioCircles 

 *By: Sean DeHart. 

 *Traces a circle of elipses on the screen. The color and size of the ellipse is controled by the audio Line In. 

 */

 

import ddf.minim.*;

 

Minim minim;

AudioInput in;

 

 

 

void setup(){ 

  size(800, 600) ;

  noStroke() ;

  minim = new Minim(this);

  minim.debugOn();

 //get a line in from Minim, default bit depth is 16;

  in = minim.getLineIn(Minim.STEREO, 512);

float a; 

float b; 

float r= 300 ; 

float theta; 

void draw() { 

  fill(0,1) ;

  rect(0,0,width, height) ;

  translate (width/2, height/2) ;

 for(int i = 0; i < in.bufferSize() – 1; i++)

  {

 

 

 

      a = r* cos(theta) ;

      b= r* sin(theta) ;

      ellipseMode(CENTER) ;

 

      //float  x=map(mouseX, 0, width, 0, 255) ;

      //float  y=map(mouseY, 0, width, 0, 255) ;

      //fill(random(255), random(x), random(y));

      fill(10+200*in.left.get(i),10+400*in.left.get(i),10+500*in.left.get(i));

      ellipse(a,b,10+500*in.left.get(i),10+500*in.left.get(i)) ;

    theta= theta+.5;

    //10+500*in.left.get(i) ,10+500*in.left.get(i)

  }

 

}

 

 

Clock (turns out there’s a better clock in their examples, but I was experimentin’) 

//By Sean DeHart a simple clock program as a test. My first running program in Processing. 

 

//initialize all variables. 

float theta; 

float r; 

float h; 

float m; 

float mta; 

float mmx; 

float mmy; 

float hhx; 

float hhy; 

float ssx;

float ssy; 

 

 

 

void setup() {

  size(150,150);

  frameRate(30);

  smooth();

 

  // Initialize Radii 

  r = 60.0f;

  theta = 0f;

  h= 30f ; 

  m= 50f ; 

}

 

void draw() {

 

  background(0);

  // Translate the origin point to the center of the screen

  translate(width/2,height/2);

  //rotate so that 12o clock is up 

  rotate(-PI/2);

  //hour and minute/second markers 

  for (theta =0 ; theta < 2*PI ; theta= theta+ 2*PI/60){

    for (mta= 0 ; mta < 2*PI ; mta= mta+ 2*PI/12){

      // Convert polar to cartesian

      float x = r * cos(theta);

      float y = r * sin(theta);

      float mx = m * cos(mta);

      float my = m * sin(mta);

      float hx = h * cos(mta);

      float hy = h * sin(mta);

      //draw the dots for hours and minutes 

      ellipseMode(CENTER);

      noStroke();

      fill(200);

      ellipse(x,y,5,5);

      ellipse(mx,my,5,5) ; 

      ellipse(hx,hy,5,5);

    }

    //convert minutes, hours and seconds to radians and plot lines with ellipse tips. 

    mmx=  r * cos (2*PI/60 *minute());

    mmy=  r * sin (2*PI/60   * minute() ) ;

    fill(200,0,0) ;

    ellipse(mmx,mmy,5,5) ; 

    hhx = h * cos(2*PI/12 * hour());

    hhy = h * sin(2*PI/12 * hour());

    fill (0,200,0) ; 

    ellipse(hhx, hhy, 5,5) ; 

    ssx= r * cos(2*PI/60 * second());

    ssy= r * sin(2*PI/60 * second());

    fill(0,0,200) ;

    ellipse(ssx, ssy, 5,5) ;

    stroke(0,200,0) ;  

    line(0,0,hhx,hhy); 

    stroke(200,00,0) ;  

    line(0,0,mmx,mmy); 

    stroke(0,0,200) ;  

    line(0,0,ssx,ssy); 

 

  }

 

}

 

 

 

Advertisement

~ by themadgadgeteer on November 27, 2008.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.