Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Graphics;
- public class SierpinskiArrowhead extends FractalPainter {
- private static final double ANGLE = Math.PI / 3.0;
- @Override
- public void paint(Graphics g, int x, int y, int length, int order) {
- turtle.reset(x, y);
- int sign = 1;
- sa(g, length, order, sign);
- }
- public void sa(Graphics g, int length, int order, int sign) {
- if (order == -1) {
- turtle.move(g, length);
- } else {
- length /= 2;
- order -= 1;
- turtle.turn(sign * ANGLE);
- sa(g, length, order, -sign);
- turtle.turn(-sign * ANGLE);
- sa(g, length, order, sign);
- turtle.turn(-sign * ANGLE);
- sa(g, length, order, -sign);
- turtle.turn(sign * ANGLE);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement