Ex Nihilo

A Processing Sketch Blog

Archive for August, 2009

Quicktime X = no love for Processing

Friday, August 28th, 2009

Today saw a bit of a setback in my latest project. I jumped the gun and installed a shiny new copy of Snow Leopard on one of my computers, the main one I’ve been using for all my Processing tinkering. I knew in advance which apps would be affected, but didn’t really think of the implications of the new Quicktime X update.

Turns out the QTJava library that sites between Processing and the Quicktime codecs that allow it to output video has been deprecated as of Quicktime X. Last night I did my first test render and it looked great; today I don’t have the ability to output .mov files anymore. So, that’s fun.

I’ve got a second computer with plain old Leopard on it that I can still render from, but I wish I’d taken advantage of that second of hesitation when I saw the “install Quicktime 7″ checkbox as I upgraded this morning. There’s probably a way to get it back, I’ll update if I find out what it is.

Update: So getting it back wasn’t hard. On the Snow Leopard install DVD there’s a folder called “Optional Installs”; run the package in there and select Quicktime 7 from the list.

Except that doesn’t seem to work. Even with Quicktime 7 I can’t seem to save out a movie file. Drat.

Posted in Uncategorized | No Comments »

WallBlank prints now up

Tuesday, August 18th, 2009

Just a quick update: I mentioned I was having some prints produced a few days ago; they’ve now been added to WallBank. I wrote up the process in Vector Output, so go have a read if you’re curious about how I did it. I have a print sitting on my desk, the paper is a thick high quality archival stock, and the ink is quite a bit richer than the on-site preview.

In an interesting case of things coming around full circle, apparently the whole idea behind WallBlank’s site was inspired by a post I wrote on the main blog last year. Seems only fitting that I’d contribute something sooner or later.

Tags: , ,
Posted in Print, Updates | No Comments »

Bring on the Trig

Monday, August 17th, 2009

2Π. Pythagorean. SOH CAH TOA. Conjures up terms of grade 10, doesn’t it? I had to go waaay back into the memory banks to even pull out a starting point for a recent trigonometry refresher.

It started like this: I had an idea to plot some points on a sphere. Now, I understand with some crafty use of the rotate() function I’d probably be able to get by without doing the math myself, but I guess I had the urge to dig a bit deeper in case I need to really know this (again) at some point.

So I started light and plotted some random points around a circle. By setting the X coordinate, I can reverse the Pythagorean equation enough to work out the math for the Y coordinate:


  X = random(0 - radius, radius);
  Y = sqrt(pow(radius, 2) - pow(X, 2));

That only gets me a positive value for Y though, which renders as a semicircle. So a bit more randomization was necessary to get the full circle:


  int rev = int(random(0, 2));
  if (rev == 1) {
    Y = sqrt(pow(radius, 2) - pow(X, 2));
  } else {
    Y = 0 - sqrt(pow(radius, 2) - pow(X, 2));
  };

Which doesn’t strike me as terribly elegant, but that’s about the limit of my coding ability.

Random Point Circle

So that was the start. Now that I can plot individual points around a circle, why not use something other than points? With some fairly basic box() objects and various rotations and transformations, things get interesting quickly:

screencap-919
screencap-9836
screencap-6176
screencap-6965
screencap-2446
screencap-5530
screencap-6119
screencap-7964

I still haven’t gotten the math for the sphere down yet, though. That was a “walk away for now, and come back to it in a few days” type of problem.

Posted in Math | 2 Comments »

Reading a Google Docs Spreadsheet

Wednesday, August 12th, 2009

There doesn’t seem to be much on the web specifically about tying together Processing and Google Docs, but it’s fairly simple when you realize the latter has a ton of export options that work pretty easily with Processing. I’m starting with CSV, though the option to work with XML will likely come in handy down the line.

Starting with a spreadsheet filled with a few dozen values, I can get at the CSV with a simple export:

Picture 2

The loadStrings function pulls in a local file or a remote URL as a String array:


String[] inputFileLines;
inputFileLines = loadStrings(
  "http://spreadsheets.google.com/pub? ->
    key=tSLqWX2BTMg1-fUyRV5shBQ&output=csv"
);

It’s fairly trivial to walk through the array and do something useful with the numbers:


inputFileIndex = 0;

while (inputFileIndex < inputFileLines.length) {
  String pieces = inputFileLines[inputFileIndex];
  if (pieces.length() > 0) {

    // do stuff with the 'pieces' string here,

  };
  inputFileIndex++;
};

The data exists as strings though, so it’s probably more useful to convert each value to float() or int() before using it. With the simple CSV file I linked up earlier as a source, I used the basic loop to assign the data points as the radii values for each of a set of spheres plotted randomly along the Y axis, or the height of a set of bars slightly tilted along the X axis:

spheres-53867
spheres-53667
blocks-52180
blocks-53883

If we were to say the linear-increasing X value is time, that makes for a couple of fun 3D graphs that even Tufte can be proud of. (Or not.)

Tags: , , ,
Posted in Google Docs | No Comments »

Vector Output

Monday, August 10th, 2009

After some idle speculation about taking my last posted sketch further, I’ve been going back and forth with a boutique print site called Wall Blank about doing a run of prints. This may be as far as I take them, or it may just be the tip of the iceberg; but more on that later (whenever I figure it out).

The immediate challenge was outputting something usable in print. I saw two options; figure out a way to use a canvas thousands of pixels across for the sake of saving out a bitmapped screen grab as a file high-resolution enough to print, or, instead find a way to output as vector.

The latter is clearly the better option and it turns out Processing has a built in PDF library that does all the hard work for you. It’s not totally straightforward; you can’t just dump the screen contents to a file, instead you have to capture the entire draw loop from the start and save that out. But even that is fairly simple. My draw loop ended up something like this:


void draw() {

  // setup the PDF save
  if (writePDF) {
    beginRecord(PDF, "frame-####.pdf");
  };

      // draw things here

  // now that the draw buffer is full,
  // dump the contents to a file
  if (writePDF) {
    endRecord();
    writePDF = false;
  };
};

The writePDF variable was an important check; without it I’d be writing PDFs on every frame. Instead I can toggle it on keypress and just capture a single frame:


void keyPressed() {
  // if 'p' is pressed, save out a PDF
  if (int(key) == 112) {
    writePDF = true;
  };
};

The resulting PDFs are surprisingly svelte; 8000 ellipses saved out to about files around 110k. My PNG screen grabs are usually at least 4 times as large.

What was particularly fun about this project is that I dared to ask whether each print could be unique, or if we were stuck working with the same source PDF for each print. I was pleasantly surprised to discover the printer was totally cool with printing a unique file for each one of the 100-print series, and happy to take advantage of that. With a slight modification to my draw loop:


void draw() {
  if ((createStuff > 0) && (createStuff < 101)) {
    beginRecord(PDF, "print-####.pdf");
  };

  if ((createStuff > 0) && (createStuff < 101)) {
    endRecord();
    createStuff++;
  };
};

...all I had to do was hit a key and wait about a minute, and voila, 100 totally unique prints, but united as a series with a common palette.

print-0007
print-0008
print-0009
print-0095

I'll make sure to mention it again on here when the prints are available for purchase, probably closer to the end of August.

Tags: ,
Posted in Print | 1 Comment »

Marbles

Thursday, August 6th, 2009

I meant to move on from all-ellipses all-the-time already, but I wanted to try some interaction effects. While adapting one of my previous sketches, I stumbled on this neat marble effect that I’ve been playing with for a few days. Though it started as a happy accident, it’s good enough that I think I might actually take this one further and produce some sort of tangible item.

But that’s going to take some time and research. In the meantime, here are a few conveniently wallpaper-sized images I’ve saved out, feel free to nab one for your desktop:

1600-2
1600-3
1600-4

Or, of course, for your iPhone:

iPhone3
iPhone4
iPhone5
iPhone6
iPhone7
iPhone8

Tags: , , ,
Posted in Uncategorized | 4 Comments »