Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float x, y;
- float lastX, lastY;
- float branchLength;
- float angle;
- float minusAngle;
- int step;
- PVector vector;
- Trunk left, right;
- Trunk(float x, float y, float branchLength, float angle, float
- minusAngle, int step) {
- PVector vec = new PVector(0, -branchLength);
- vec.rotate(angle);
- lastX = x + vector.x;
- lastY = y + vector.y;
- if (step > 0) {
- left = new Trunk(last, lastY, branchLength * .75, angle -
- minusAngle,
- diffAngle, step - 1);
- right = new Trunk(lastX, lastY, branchLength * .75, angle +
- minusAngle, diffAngle, step - 1);
- }
- }
- void drawMe() {
- stroke(0, 70);
- strokeWeight(4);
- if ( right != null)
- right.drawMe();
- if (left != null)
- left.drawMe();
- pushMatrix();
- translate(x, y);
- rotate(angle);
- noFill();
- pushStyle();
- fill(c);
- popStyle();
- popMatrix();
- }
Add Comment
Please, Sign In to add comment