Guest User

Untitled

a guest
Apr 25th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. PImage subject;
  2. float baseStart;
  3. float baseLength;
  4. float xVector;
  5. float yVector;
  6. float hStart;
  7. float hLength;
  8.  
  9. void setup() {
  10. size(600, 440);
  11. background(128);
  12. subject = loadImage("trey.jpg");
  13. image(subject, 0, 0);
  14. stroke(0, 0, 0, 75);
  15. smooth();
  16. baseStart = 3;
  17. baseLength = 20;
  18. }
  19.  
  20. void draw() {
  21. hStart = random(-baseStart, baseStart);
  22. hLength = random(baseLength);
  23.  
  24. if (mousePressed == true) {
  25.  
  26. if (mouseX>=width/2) {
  27. xVector = random(hLength);
  28. } else {
  29. xVector = -random(hLength);
  30. }
  31.  
  32. if (mouseY>=height/2) {
  33. yVector = random(hLength);
  34. } else {
  35. yVector = -random(hLength);
  36. }
  37.  
  38. line(mouseX+hStart, mouseY+hStart, mouseX+xVector, mouseY+yVector);
  39. }
  40. }
Add Comment
Please, Sign In to add comment