Guest User

Untitled

a guest
Feb 23rd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. float x, y;
  2. float lastX, lastY;
  3. float branchLength;
  4. float angle;
  5. float minusAngle;
  6. int step;
  7. PVector vector;
  8.  
  9. Trunk left, right;
  10.  
  11. Trunk(float x, float y, float branchLength, float angle, float
  12. minusAngle, int step) {
  13.  
  14. PVector vec = new PVector(0, -branchLength);
  15. vec.rotate(angle);
  16. lastX = x + vector.x;
  17. lastY = y + vector.y;
  18.  
  19. if (step > 0) {
  20. left = new Trunk(last, lastY, branchLength * .75, angle -
  21. minusAngle,
  22. diffAngle, step - 1);
  23. right = new Trunk(lastX, lastY, branchLength * .75, angle +
  24. minusAngle, diffAngle, step - 1);
  25. }
  26. }
  27.  
  28. void drawMe() {
  29. stroke(0, 70);
  30. strokeWeight(4);
  31. if ( right != null)
  32. right.drawMe();
  33. if (left != null)
  34. left.drawMe();
  35.  
  36. pushMatrix();
  37. translate(x, y);
  38. rotate(angle);
  39. noFill();
  40. pushStyle();
  41. fill(c);
  42.  
  43. popStyle();
  44. popMatrix();
  45. }
Add Comment
Please, Sign In to add comment