Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. PImage[] images = new PImage[10];
  2. int x = 0;
  3. int y = 0;
  4.  
  5. import processing.video.*;
  6. Capture cam;
  7.  
  8.  
  9. void setup() {
  10. //size(4032, 3024);
  11. size(1920, 1080);
  12. images[0] = loadImage("IMG_1.JPG");
  13. images[1] = loadImage("IMG_2.JPG");
  14. images[2] = loadImage("IMG_3.JPG");
  15. images[3] = loadImage("IMG_4.JPG");
  16. images[4] = loadImage("IMG_5.JPG");
  17. images[5] = loadImage("IMG_6.JPG");
  18. images[6] = loadImage("IMG_7.JPG");
  19. images[7] = loadImage("IMG_8.JPG");
  20. images[8] = loadImage("IMG_9.JPG");
  21. images[9] = loadImage("IMG_10.JPG");
  22. frameRate(5);
  23.  
  24.  
  25. String[] cameras = Capture.list();
  26. if (cameras.length == 0) {
  27. println("There are no cameras available for capture.");
  28. exit();
  29. } else {
  30. println("Available cameras:");
  31. for (int i = 0; i < cameras.length; i++) {
  32. println(cameras[i]);
  33. }
  34. }
  35.  
  36. cam = new Capture(this, cameras[3]);
  37. cam.start();
  38. }
  39.  
  40. void draw() {
  41. if (cam.available() == true) {
  42. cam.read();
  43. }
  44. image(cam, 0, 0);
  45.  
  46. x = int(random(0, width));
  47. y = int(random(0, height));
  48. int randomx = int(random(x-100, x+100));
  49. int randomy = int(random(y-100, y+100));
  50. int index = int(random(0, 10));
  51. PImage smallImg = images[index].get(randomx, randomy, 1000, 1000);
  52. image(smallImg, x, y);
  53.  
  54.  
  55. //x = x + 50;
  56. //if (x > width) {
  57. // x = 0;
  58. // y = y + 50;
  59. // if (y > height) {
  60. // y = 0;
  61. // }
  62. //}
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement