Advertisement
MrMusAddict

Color Cube

Feb 7th, 2018
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 KB | None | 0 0
  1. PImage photo; //must be at most 600x600
  2.  
  3. ArrayList<cPoint> points = new ArrayList<cPoint>();
  4.  
  5. void setup() {
  6.   size(1200, 600, P3D);
  7.   ortho();
  8.   photo = loadImage("edit.jpg");
  9.   for (int i = 0; i < photo.pixels.length; i++) {
  10.     points.add(new cPoint(photo.pixels[i]));
  11.   }
  12. }
  13.  
  14. void draw() {
  15.   background(200);
  16.   image(photo, 0, 0);
  17.   translate(3*width/4, height/2, 0);
  18.   rotateX(PI-PI/8.0);
  19.   rotateY(frameCount*PI/150+3.0*PI/2.0);
  20.   strokeWeight(1);
  21.   stroke(0);
  22.   noFill();
  23.   scale(1.5, 1.5, 1.5);
  24.   box(255, 255, 255);
  25.   translate(-127, -127, -127);
  26.  
  27.   strokeWeight(20);
  28.   for (cPoint p : points) {
  29.     p.show();
  30.   }
  31. }
  32.  
  33. class cPoint {
  34.  
  35.   PVector pos;
  36.   color col;
  37.  
  38.   cPoint(color c) {
  39.     col = c;
  40.     pos = new PVector(red(c), green(c), blue(c));
  41.   }
  42.  
  43.   void show() {
  44.     stroke(col);
  45.     point(pos.x, pos.y, pos.z);
  46.   }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement