Advertisement
Guest User

asdasd

a guest
Jan 24th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1.  
  2. void setup() {
  3. size(800, 800);
  4. // println(rx);
  5. // println(ry);
  6. // println(float(ry)/rx);
  7. }
  8.  
  9. float a = 0;
  10. float l = 400;
  11. int rx = int(random(100, 200));
  12. int ry = int(random(100, 200));
  13. float prev;
  14. float current;
  15. float x = cos(a)*l;
  16. float y = sin(a)*l;
  17. void draw() {
  18. background(0);
  19. translate(width/2, height/2);
  20. y = sin(a)*l;
  21. x = cos(a)*l;
  22.  
  23. stroke(255);
  24. line(0, 0, x, y);
  25. strokeWeight(10);
  26. point(width/2, height/2);
  27. strokeWeight(1);
  28. a += PI/36;
  29.  
  30. if (checkStatus(prev, curr, rx, ry)) {
  31. stroke(255);
  32. } else {
  33. stroke(0);
  34. }
  35. point(rx, ry);
  36. // println(y/x);
  37. }
  38.  
  39. boolean checkStatus(float prev, float curr, int x, int y) {
  40. float slope = float(ry)/rx;
  41. if (slope <= prev && slope >= curr || slope >= prev && slope <= curr) {
  42. return true;
  43. } else {
  44. return false;
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement