Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. //save visuals to screenshots in file folder
  2. //save mousepositions to txt file
  3.  
  4.  
  5. float circleX, circleY;
  6.  
  7. String[] positions;
  8.  
  9. String[] savedPositions;
  10.  
  11. void setup()
  12. {
  13. size(300,300);
  14. smooth();
  15. circleX=0;
  16. circleY=0;
  17. positions = new String[0];
  18.  
  19. savedPositions = loadStrings("positions.txt");
  20.  
  21. frameRate(30);
  22. }
  23.  
  24. void draw()
  25. {
  26. background(0);
  27. fill(255);
  28. noStroke();
  29. ellipse(width/2,height/2, 150,150);
  30. stroke(0);
  31. strokeWeight(3);
  32. pushMatrix();
  33. translate(width/2, height/2);
  34. rotate(map(mouseY, 0, height, 0, PI));
  35. line(0,0, 0,60);
  36. popMatrix();
  37.  
  38. fill(128);
  39. String coordinateString = savedPositions[frameCount%savedPositions.length];
  40. int[] coordinateNumbers = int(split(coordinateString, ","));
  41. ellipse(coordinateNumbers[0], coordinateNumbers[1], 50,50);
  42.  
  43. fill(255);
  44. stroke(0);
  45. ellipse(circleX, circleY, 50, 50);
  46.  
  47. }
  48.  
  49. void mouseMoved()
  50. {
  51. circleX=mouseX;
  52. circleY=mouseY;
  53. positions = append(positions, mouseX + "," + mouseY);
  54. }
  55.  
  56. void keyPressed()
  57. {
  58. if(key == ' ')
  59. {
  60. //saves screenshot on each keypress
  61. // saveFrame("frame-####.png");
  62.  
  63. //saves mouse coordinates to a txt file from array ofray of coordinates on each keypress
  64. saveStrings("positions.txt", positions);
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement