Advertisement
mkeyno

​Processing pixelized program for POV

Jan 9th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.32 KB | None | 0 0
  1. PImage img,black_b,image_load;
  2. PrintWriter output;
  3.  
  4. int SQL;
  5. float led_t;
  6. byte[] pov_data;
  7. int line_num=200;
  8. String _OUTPUT="";
  9.  
  10.  
  11.  
  12. void setup()
  13. {
  14. output = createWriter(_OUTPUT);
  15. black_b= createImage(SQL, SQL, RGB);
  16. black_b.loadPixels();
  17. for (int i = 0; i < black_b.pixels.length; i++) {  black_b.pixels[i] = color(0, 0, 0); }
  18. black_b.updatePixels();
  19. background(black_b);
  20.  img = loadImage("myImage.jpg");
  21. }
  22. int l=0;
  23. void draw()
  24. {
  25.   if(l>=line_num) {noLoop();output.flush();output.close();}
  26.   background(black_b);
  27.   pushMatrix();
  28.              imageMode(CENTER);  
  29.              translate(SQL/2, SQL/2);
  30.               rotate(radians(l*360/line_num));
  31.               image(img, 0, 0);
  32.   popMatrix();
  33.   pushMatrix();
  34.        for(int i=0;i<144;i++)
  35.        {
  36.          color c = get(int(i*led_t+led_t/2), int(SQL/2));
  37.          output.print((char)red(c)+""+(char)green(c)+""+(char)blue(c));    
  38.         // print((char)red(c)+""+(char)green(c)+""+(char)blue(c)+";");
  39.           fill(c);
  40.           rect(i*led_t, (SQL/2)-(led_t/2),led_t,led_t);
  41.       }
  42.     //  println();
  43.    popMatrix();
  44.   // delay(500);
  45.   l++;
  46. }
  47.  
  48. void keyPressed()
  49. {
  50.   output.flush();  // Writes the remaining data to the file
  51.   output.close();  // Finishes the file
  52.   exit();  // Stops the program
  53. }
  54.  
  55.  
  56.  
  57. void mousePressed(){  loop();}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement