Ostrich-Egg Bot and Processing
One of the main goals I have with using the Ostrich-Egg Bot is to generate art for it via Processing. I’ve successfully drawn and etched a variety of random svg graphics onto a variety of surfaces. Next step was to get that art from Processing.
Turned out to be a bit more difficult than I expected: Processing has no native API call for exporting svg’s (that I can find). But I finally grasped the fact that it can export pdf files via its pdf library. And these, when imported into Inkscape, have the exact paths you need to plot. Here’s a vid of the etcher in action based on a Processing-generated image:
And here’s the source for a simple Processing sketch that makes use of this: The sketch draws a bunch of overlapping circles, larger on the bottom, smaller on the top, and makes sure there is no seam on the edge:
// eggbot_circles01 import processing.pdf.*; int eggWidth = 3200; int eggHeight = 800; int minSize = 32; int maxSize = 256; void setup() { size(eggWidth, eggHeight); smooth(); background(255); frame.setTitle("Eggbot: Circles01"); noFill(); beginRecord(PDF, "processingCircles.pdf"); } void draw() { float[] pos = { random(width), random(minSize/2, height-maxSize/2) }; float eSize = map(pos[1], minSize/2, height-maxSize/2, minSize, maxSize); ellipse(pos[0], pos[1], eSize, eSize); // Tile the circles on the x axis: if (pos[0] < eSize/2) { ellipse(pos[0]+width, pos[1], eSize, eSize); } else if (pos[0] > width-eSize/2) { ellipse(pos[0]-width, pos[1], eSize, eSize); } } void keyPressed() { if (key == 's') { endRecord(); exit(); } }
When the sketch is going, press ‘s’ to save an image, and quit. It actually raises an exception, but the image saves… not sure what’s going on…
From there it’s a simple matter of importing the pdf into Inkscape. I discovered however that its size was bigger than what was defined in the sketch, so I had to resize it to fit the Ostrich-Egg Bot’s drawing area. Here is a close-up of the etcher in action:
And here’s a shot of the final product:
So, not the most amazing thing, but one step closer…