| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,49 @@ | |||
| 1 | + /** | ||
| 2 | + * Extrusion. | ||
| 3 | + * | ||
| 4 | + * Converts a flat image into spatial data points and rotates the points | ||
| 5 | + * around the center. | ||
| 6 | + */ | ||
| 7 | + | ||
| 8 | + PImage a; | ||
| 9 | + boolean onetime = true; | ||
| 10 | + int[][] aPixels; | ||
| 11 | + int[][] values; | ||
| 12 | + float angle; | ||
| 13 | + | ||
| 14 | + void setup() { | ||
| 15 | + size(640, 360, P3D); | ||
| 16 | + | ||
| 17 | + aPixels = new int[width][height]; | ||
| 18 | + values = new int[width][height]; | ||
| 19 | + noFill(); | ||
| 20 | + | ||
| 21 | + // Load the image into a new array | ||
| 22 | + // Extract the values and store in an array | ||
| 23 | + a = loadImage("ystone08.jpg"); | ||
| 24 | + a.loadPixels(); | ||
| 25 | + for (int i = 0; i < a.height; i++) { | ||
| 26 | + for (int j = 0; j < a.width; j++) { | ||
| 27 | + aPixels[j][i] = a.pixels[i*a.width + j]; | ||
| 28 | + values[j][i] = int(blue(aPixels[j][i])); | ||
| 29 | + } | ||
| 30 | + } | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + void draw() { | ||
| 34 | + background(0); | ||
| 35 | + translate(width/2, height/2, -height/2); | ||
| 36 | + scale(2.0); | ||
| 37 | + | ||
| 38 | + // Update and constrain the angle | ||
| 39 | + angle += 0.005; | ||
| 40 | + rotateY(angle); | ||
| 41 | + | ||
| 42 | + // Display the image mass | ||
| 43 | + for (int i = 0; i < a.height; i += 4) { | ||
| 44 | + for (int j = 0; j < a.width; j += 4) { | ||
| 45 | + stroke(values[j][i], 255); | ||
| 46 | + line(j-a.width/2, i-a.height/2, -values[j][i], j-a.width/2, i-a.height/2, -values[j][i]-10); | ||
| 47 | + } | ||
| 48 | + } | ||
| 49 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments