diff --git a/java/examples/Topics/File IO/SaveFrames/SaveFrames.pde b/java/examples/Topics/File IO/SaveFrames/SaveFrames.pde deleted file mode 100644 index ba7d8b000..000000000 --- a/java/examples/Topics/File IO/SaveFrames/SaveFrames.pde +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Save Frames - * by Daniel Shiffman. - * - * This example demonstrates how to use saveFrame() to render - * out an image sequence that you can assemble into a movie - * using the MovieMaker tool. - */ - -// A boolean to track whether we are recording are not -boolean recording = false; - -void setup() { - size(640, 360); - smooth(); -} - -void draw() { - background(0); - - // An arbitrary oscillating rotating animation - // so that we have something to render - for (float a = 0; a < TWO_PI; a+= 0.2) { - pushMatrix(); - translate(width/2, height/2); - rotate(a+sin(frameCount*0.004*a)); - stroke(255); - line(-100, 0, 100, 0); - popMatrix(); - } - - // If we are recording call saveFrame! - // The number signs (#) indicate to Processing to - // number the files automatically - if (recording) { - saveFrame("output/frames####.png"); - } - - // Let's draw some stuff to tell us what is happening - // It's important to note that none of this will show up in the - // rendered files b/c it is drawn *after* saveFrame() - textAlign(CENTER); - fill(255); - if (!recording) { - text("Press r to start recording.", width/2, height-24); - } - else { - text("Press r to stop recording.", width/2, height-24); - } - - // A red dot for when we are recording - stroke(255); - if (recording) { - fill(255, 0, 0); - } else { - noFill(); - } - ellipse(width/2, height-48, 16, 16); -} - -void keyPressed() { - - // If we press r, start or stop recording! - if (key == 'r' || key == 'R') { - recording = !recording; - } -} - diff --git a/java/examples/Topics/File IO/SavingFrames/SavingFrames.pde b/java/examples/Topics/File IO/SavingFrames/SavingFrames.pde deleted file mode 100644 index 1f5c5ef06..000000000 --- a/java/examples/Topics/File IO/SavingFrames/SavingFrames.pde +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Saving Frames example - * by Daniel Shiffman. - * - * This example demonstrates how to use saveFrame() to render - * out an image sequence that you can assemble into a movie - * using the MovieMaker tool. - */ - -// A boolean to track whether we are recording are not -boolean recording = false; - -void setup() { - size(640, 360); - smooth(); -} - -void draw() { - background(0); - - // An arbitrary oscillating rotating animation - // so that we have something to render - for (float a = 0; a < TWO_PI; a+= 0.2) { - pushMatrix(); - translate(width/2, height/2); - rotate(a+sin(frameCount*0.004*a)); - stroke(255); - line(-100, 0, 100, 0); - popMatrix(); - } - - // If we are recording call saveFrame! - // The number signs (#) indicate to Processing to - // number the files automatically - if (recording) { - saveFrame("output/frames####.png"); - } - - // Let's draw some stuff to tell us what is happening - // It's important to note that none of this will show up in the - // rendered files b/c it is drawn *after* saveFrame() - textAlign(CENTER); - fill(255); - if (!recording) { - text("Press r to start recording.", width/2, height-24); - } - else { - text("Press r to stop recording.", width/2, height-24); - } - - // A red dot for when we are recording - stroke(255); - if (recording) { - fill(255, 0, 0); - } else { - noFill(); - } - ellipse(width/2, height-48, 16, 16); -} - -void keyPressed() { - - // If we press r, start or stop recording! - if (key == 'r' || key == 'R') { - recording = !recording; - } -} - diff --git a/java/examples/Topics/Image Processing/Extrusion/Extrusion.pde b/java/examples/Topics/Image Processing/Extrusion/Extrusion.pde new file mode 100755 index 000000000..7d3520dc4 --- /dev/null +++ b/java/examples/Topics/Image Processing/Extrusion/Extrusion.pde @@ -0,0 +1,49 @@ +/** + * Extrusion. + * + * Converts a flat image into spatial data points and rotates the points + * around the center. + */ + +PImage a; +boolean onetime = true; +int[][] aPixels; +int[][] values; +float angle; + +void setup() { + size(640, 360, P3D); + + aPixels = new int[width][height]; + values = new int[width][height]; + noFill(); + + // Load the image into a new array + // Extract the values and store in an array + a = loadImage("ystone08.jpg"); + a.loadPixels(); + for (int i = 0; i < a.height; i++) { + for (int j = 0; j < a.width; j++) { + aPixels[j][i] = a.pixels[i*a.width + j]; + values[j][i] = int(blue(aPixels[j][i])); + } + } +} + +void draw() { + background(0); + translate(width/2, height/2, -height/2); + scale(2.0); + + // Update and constrain the angle + angle += 0.005; + rotateY(angle); + + // Display the image mass + for (int i = 0; i < a.height; i += 4) { + for (int j = 0; j < a.width; j += 4) { + stroke(values[j][i], 255); + line(j-a.width/2, i-a.height/2, -values[j][i], j-a.width/2, i-a.height/2, -values[j][i]-10); + } + } +}