Posts Tagged ‘processing.org’

Mental Radio (2007)

Wednesday, April 23rd, 2008

mental radio

A tool for exploring extrasensory perception

Interactive installation by Ulrika Sparre (2007). Produced at the Interactive Institute with Sparre as Artist in Residence. Programming and interface design by Fredrik Bridell.

Mental Radio contains an archive of drawings. The viewer is invited to try to guess the current drawing, hidden from view, and try to make a similar drawing.

(more…)

Volumatrix

Saturday, December 29th, 2007

Volumatrix (still)

Interactive animation (2007)

Launch Volumatrix

Made at the Insteractive Institute Art & Technology Program.

This is a sketch I made for visualizing what it might look like to “explode” an image into three-dimensional space. A source image is sampled at low resolution and the pixels are positioned in 3d space either along a cone or with a random Z coordinate. The resulting shape can be rotated and seen from any angle.

This was a sketch done in an early phase of a design process for a physical installation. It was made using Processing.

Here’s the source code and the animation on a web page. If you download the source code and want to run it in Processing you’ll need to put some image files in the same folder and update the file names in the source code.

Pentamorph

Saturday, December 29th, 2007

Pentamorph screenshot

Launch Pentamorph

Animation made at the Interactive Institute (2007).

This is a quick sketch for a moving logo that I made at the request of Ingvar Sjöberg.

It’s a pentagon with an inscribed shape that moves from a point in the center to an inscribed pentagon, upside-down with respect to the outer one. About halfway through the motion, the inner shape becomes a pentagram.

Made with Processing.

How to get started using mobile processing

Wednesday, December 12th, 2007

Processing is a free, open-source programming environment based on Java and the weapon of choice for most people doing artistic productions that require a bit of coding. Get it at processing.org

Mobile Processing is a cousin of Processing, but aimed at mobile phones and other smaller devices.

The problem

I want to be able to write simple programs on my computer and run them on my mobile phone. My computer is a Windows XP laptop with bluetooth, my phone is a java-enabled phone, also with bluetooth.

The solution

I did it by installing mobile processing, exporting to MIDlet and then transferring the jar file to my phone using Windows XP’s Bluetooth File Transfer Wizard. All of this is absolutely free, btw.

Setup

  1. Download and install a Java JDK. See how to set up java development.
  2. Download and install Sun Java Wireless Toolkit for CLDC (WTK)
    http://java.sun.com/products/sjwtoolkit/
  3. Download and install mobile processing.Since you’ve installed Java yourself, get the expert version. To install, just to unzip the archive where you want to have it, e.g. c:\sdk\mobile
    http://mobile.processing.org
  4. Restarting your computer at this point is probably a good idea.
  5. Start mobile processing by running the start-expert.bat in the mobile processing

sendkeys - a handy Processing app

Wednesday, November 14th, 2007

sendkeys (screenshot)

I wrote this little Processing application I’d thought I’d share with you.

It opens a little window with a black circle in it. When you press a key - any key - whatever you press gets sent to your serial port. Also, the circle turns white just to let you know your program is live.

The Processing code that really does anything is just this:

In setup():

String[] ports = Serial.list();
serial = new Serial(this, ports[ports.length-1], baudRate);

and then in keyReleased():

serial.write(key);

That’s it. Very handy.

Download the sendkeys processing code

Processing

Tuesday, November 13th, 2007

Processing is an easy-to-learn programming language that is geared towards visual programs. It’s completely free and even completely open source. It is very easy to make simple things and still powerful enough to do some really interesting things. There are lots of examples of what has been done at the Processing.org site. Processing builds to applets (so you can post them live on a web page), or to executable files. And it works for Windows, Mac and Linux.

Download Processing and learn more from http://processing.org

How to use min() and max() - and a DIY unit test

Thursday, November 8th, 2007

So, there I was, coding a little thing in Processing. I was just testing out this thing where the user could drag control points around in a window, and I just needed to make sure she didn’t drag them out of bounds. What I want to achieve is this: I have a value that comes from somewhere - an x coordinate from user interaction, say - and I want to limit that value so it’s not smaller than the left edge and not bigger than the right one. I’ve done this lots of times before but I always have to think about which way is which. Well, here it is, once and for all.

The tricky part is that in this case you want to use min to check for the maximum value, and max to check for the minimum value. Very backwards.

int limit(int minValue, int value, int maxValue){
return max(minValue, min(value, maxValue));
}

The inner min(value, maxValue) takes the value of whichever is smaller - the value or the max value - so that’s checking that the value is not too big. The outer max checks the lower limit.

If you want to have a look at the actual code I wrote (complete with comments and error checking) there’s an attached file with the original Processing (in this case, pure Java) code.

Since I was doing this in Processing (and for some reason not from Eclipse but from the rather crappy Processing IDE) there’s not really any unit testing framework around - so I did that as well. The idea behind unit testing is that if you know how your method is supposed to work, it’s a good idea to verify that it does indeed do what you think it does. This seems like a pretty obvious idea, but people were coding along happily for years (and many still are) before thinking of actually testing the parts before testing the whole. The simplest do-it-yourself unit testing takes about three lines of code to set up in whatever language you’re using. The test method goes something like this:

void assertEqual(int expected, int actual, String message){
if (actual != expected){
System.err.println("Assertion failed (" + message + "): expected " + expected + ", got " + actual);
}
}

This works even better in non-typed languages where you don’t have to make one version for ints and one for floats and so on. If you’re doing more serious development you should of course take the time to dig up a serious unit testing framework for you language (such as JUnit for Java).

The original processing code is here: Processing code - Limit utility

Update: DOH! I just found out that somebody already thought of this. There’s a Processing method contrain(value, min, max) that does the same thing!