window resizing in processing

Nikolaus Gradwohl2009-03-08T19:50:00+01:00

The following processing code shows how to resize a processing window from your code. the resizeApp methdo calculates the difference between the frame size and the size of the actual drawing area and adds it to the new size. then the application-frame is resized.

void setup() {
  size(320,200);
}

int col = 0;

void draw() {
  background(col);
  stroke(255,0,0);
  line(0,0,width, height);
  line(0,height,width,0);
}

void mousePressed() {
  if (col == 0) {
    resizeApp( 640, 400 );
    col = 255;
  } else {
    resizeApp( 320, 200 );
    col = 0;
  }
}

void keyPressed() {
  exit();
}

void resizeApp( int w, int h ) {
  int delta = frame.getHeight()-height;
   resize( w, h );
   frame.setSize( w, h + delta );
}
read more ...

processing ical-flowers-2.0

Nikolaus Gradwohl2009-02-15T08:15:00+01:00

I made a new version of the ical flowers sketch i wrote in dezember. This time it doesn't only show a flower for every event in my calender, it also shows

  • the current weather (using the rubyweather library)
  • the current temperature outside
  • the min/max temperature outside
  • the current temperature inside ( using my arduino i2c thermometer sketch)
  • the sky color changes depending on the current time

ical-flowers screen1

ical-flowers screen2

the system consists of a ruby-proxy, an arduino sketch and a processing sketch.

the ruby proxy starts a web-server on port 2000. It fetches the current weather using the rubyweather gem, fetches the events from the configured caldav calenders, and fetches the current temperature from the arduino using ruby-serial

the arduino sketch is basicaly the same as in this blog post. the only change is that the arduino only sends the temperature when the host sends a 'C' over the serial line

the processing sketch finally fetches the data via http from the proxy and displays it ( using my icap4p library. the screen is updated every 1/2 hour using the method described here

the code can be downloaded here

it's published under the LGPL

have fun :-)

read more ...

abstract art generator

Nikolaus Gradwohl2009-02-06T18:29:00+01:00

my latest processing-sketch is a generator for abstract art.

just click on the applet to generate a new image

abstract art generator

read more ...

Processing links

Nikolaus Gradwohl2009-02-05T18:02:00+01:00

http://www.processing.org/ the mother of all processing sites :-)

http://www.arduino.cc/ a language and a microcontroller board that that go very well with processing

http://mobile.processing.org/ a mobile phone edition of porcessing

http://www.openvisuals.org/ a site showing how to visualize data using processing

http://www.openprocessing.org/ a site collection processing sketches

http://www.processingblogs.org/ a processing meta blog

http://www.rmx.cz/monsters/ a collection of black'n'white monsters - coded in processing (one of them has been written by me :-) )

http://www.local-guru.net/blog/tag/processing my own site

two really great art collections using processing

http://www.complexification.net/gallery/

http://abandonedart.org/

some artists using processing

http://www.flight404.com/blog/?cat=1

http://www.toxi.co.uk/

http://www.benfry.com/

http://www.groupc.net/

Books:

make things talk

visualizing data

Processing: A Programming Handbook for Visual Designers and Artists

read more ...

extra low framerates in Processing

Nikolaus Gradwohl2009-01-29T04:45:00+01:00

when you want to write a processing sketch, that doesn't redraw several times a second, but updates the main method only once in a while (for example once per hour or minute) the following code can be used to start a thread that triggers a redraw after a delay. Just make sure the setup method calls the noLoop() methode and than start the thread calling start( millisecondsToWait );

void setup() {
  size(300,300);
  smooth();
  noLoop(); // <- turn off the processing loop

  start( 20 * 1000 ); // <- start the thread
}

void draw() {
  background( 255 );
  // draw some random circles
  for ( int i =0; i< 10; i++) {
    color c = color(random( 255 ));
    fill( c );
    stroke( c );
    int radius = int(random( 100 )+ 40);
    ellipse( random( width ), random( height ), radius, radius );     
  }  
}

void start( final int mil ) { //<- mil has to be final to be accessible in run() 
   new Thread() { 
   public void run() {
     while( true ) {     
        delay( mil );
        redraw(); 
      }
   }
 }.start();
}
read more ...

Random numbers with MobileProcessing

Nikolaus Gradwohl2009-01-25T08:14:00+01:00

I wrote my first sketch in MobileProcessing. MobileProcessing is a processing dialect, that can be used to write apps for java-capable mobile phones.

The application can be used to generate random numbers. every key-event shows a new random number.

/**
  a random number generator by
  <a href="http://www.local-guru.net/blog">Guru</a>
*/

PFont font;
int rnd = 0;

void setup() {  
  font = loadFont( FACE_PROPORTIONAL, STYLE_PLAIN, SIZE_LARGE );
  textFont( font );
  textAlign( CENTER );
  fill(0);
  rnd = random(0,100000);
  noLoop();
}

void draw() {
  background(255);
  text( "\n\n\n"+rnd, 0, 0, width, height );
}

void keyPressed() {
  rnd = random(0,100000);
  redraw();
}
read more ...

Processing sketch on fire

Nikolaus Gradwohl2009-01-18T07:50:00+01:00

I just made another little demo in processing. in fact i rewrote a little demo i did 15 years ago in pascal on a dos-box

fire-screenshot

read more ...

Training Bike Visualization

Nikolaus Gradwohl2008-12-08T14:58:00+01:00

i wrote a processing sketch to visualize and record sessions on a training bike. To calculate the rotation-speed of my training bike i hooked up 2 reed-switches to my arduino and taped them to my training bike. Than i sticked a rare earth magnet on each pedal.

the processing sketch draws a small figure on a bike which is animated at the same speed as the bike.

the sketch also records the timestamps to a log file for later analysis.

training bike

read more ...

processing ical-flowers

Nikolaus Gradwohl2008-12-06T22:42:00+01:00

I just made a processing sketch using my ical4p library. The programm draws a flower for every event in a given ical-file. The more events the calender has, the more beautifull the flower-garden is :-)

ical-flowers

read more ...

ical4p Processing lib

Nikolaus Gradwohl2008-12-06T22:26:00+01:00

i have written a small wrapper around ical4j written by Ben Fortuna. This allows to write processing sketches, that visualize data from ical files.

i included a small example in the lib showing how to draw a timeline based on an ical file.

i also have set up a project-page for it. The libray is released under the LGPL.

read more ...