import java.awt.Color;
import java.awt.Point;
import sk.upjs.jpaz2.Turtle;
public class ChytraTurtle extends Turtle {
        public void vystredenyStvorec(double dlzkaStrany) {
                this.penUp();
                this.turn(-90);
                this.step(dlzkaStrany / 2);
                this.turn(-90);
                this.step(dlzkaStrany / 2);
                this.turn(180);
                this.penDown();
                for (int i = 1; i <= 4; i++) {
                        this.step(dlzkaStrany);
                        this.turn(90);
                }
                this.penUp();
                this.step(dlzkaStrany / 2);
                this.turn(90);
                this.step(dlzkaStrany / 2);
                this.turn(-90);
                this.penDown();
        }
        public void ciarkaBodkaCiarka(double dlzka) {
                this.step(dlzka / 4);
                this.penUp();
                this.step(dlzka / 4);
                this.setFillColor(Color.orange);
                this.dot(dlzka / 8);
                this.step(dlzka / 4);
                this.penDown();
                this.step(dlzka / 4);
        }
        public void slniecko(double polomer) {
                this.setPenColor(Color.orange);
                for (int i = 0; i < 36; i++) {
                        this.step(2 * polomer);
                        this.step(-2 * polomer);
                        this.turn(10);
                }
                this.dot(polomer);
        }
        public void stvorec(double dlzkaStrany) {
                for (int i = 0; i < 4; i++) {
                        this.step(dlzkaStrany);
                        this.turn(90);
                }
        }
        public void obrazec(double dlzkaStrany) {
                this.setPenColor(Color.blue);
                this.setPenWidth(2);
                for (int i = 0; i < 10; i++) {
                        this.stvorec(dlzkaStrany);
                        this.turn(90);
                        this.step(dlzkaStrany / 2);
                        this.turn(36);
                        this.turn(-90);
                }
        }
        public void mriezka(double rozmer) {
                this.setPosition(new Point(10, 10));
                this.turn(90);
                for (int i = 0; i < 9; i++) {
                        this.step(rozmer * 8);
                        this.setY(10 + (i + 1) * rozmer);
                        this.setX(10);
                }
                this.setPosition(new Point(10, 10));
                this.turn(90);
                for (int i = 0; i < 9; i++) {
                        this.step(rozmer * 8);
                        this.setX(10 + (i + 1) * rozmer);
                        this.setY(10);
                }
        }
        public void vyplnenyStvorec(double strana) {
                this.openPolygon();
                for (int i = 0; i < 4; i++) {
                        this.step(strana);
                        this.turn(90);
                }
                this.closePolygon();
        }
        public void hviezda4(double dlzkaCipu, double uhol) {
                this.setFillColor(Color.yellow);
                this.openPolygon();
                this.setPenColor(Color.red);
                this.setPenWidth(4);
                for (int i = 0; i < 4; i++) {
                        this.step(dlzkaCipu);
                        this.turn(180 - uhol);
                        this.step(dlzkaCipu);
                        this.turn(-(90 - uhol));
                }
                this.closePolygon();
        }
        public void diamant(double uhol, double dlzkaStrany) {
                for (int i = 0; i < 3; i++) {
                        this.turn(-uhol);
                        this.step(dlzkaStrany);
                        this.turn(2 * uhol);
                        this.step(dlzkaStrany);
                        this.turn(180 - 2 * uhol);
                        this.step(dlzkaStrany);
                        this.turn(2 * uhol);
                        this.step(dlzkaStrany);
                        this.turn(300 - uhol);
                }
        }
        public void pochodzkaKruh(int pocetKrokov, double polomer) {
                double xStart = getX();
                double yStart = getY();
                for (int i = 0; i < pocetKrokov; i++) {
                        this.turn(Math.random() * 360);
                        this.step(5);
                        if (this.distanceTo(xStart, yStart) > polomer) {
                                this.step(-5);
                        }
                }
        }
        public void pochodzkaTrojKruh(int pocetKrokov, double polomer) {
                double xStart = getX();
                double yStart = getY();
                this.penUp();
                for (int i = 0; i < pocetKrokov; i++) {
                        this.turn(Math.random() * 360);
                        this.step(5);
                        if (this.distanceTo(xStart, yStart) > polomer) {
                                this.step(-5);
                        }
                        if (this.distanceTo(xStart, yStart) < polomer / 3) {
                                this.penUp();
                        } else {
                                penDown();
                        }
                        if ((this.distanceTo(xStart, yStart) < (2 * polomer / 3))
                                        && (this.distanceTo(xStart, yStart) > polomer / 3)) {
                                this.setPenColor(Color.blue);
                        }
                        if (this.distanceTo(xStart, yStart) > (2 * polomer / 3)) {
                                this.setPenColor(Color.red);
                        }
                }
        }
        public void pochodzkaStvorec(int pocetKrokov, double strana) {
                double xL = this.getX() - strana / 2;
                double xP = this.getX() + strana / 2;
                double yH = this.getY() - strana / 2;
                double yD = this.getY() + strana / 2;
                for (int i = 0; i < pocetKrokov; i++) {
                        this.turn(Math.random() * 360);
                        this.step(5);
                        this.setPenColor(new Color((int)(Math.random()*256),(int)( Math.random()*256),(int)(Math.random()*256)));
                        if (this.getX() < xL) {
                                this.step(-5);
                        }
                        if (this.getX() > xP) {
                                this.step(-5);
                        }
                        if (this.getY() < yH) {
                                this.step(-5);
                        }
                        if (this.getY() > yD) {
                                this.step(-5);
                        }
                }
        }
        public void vymenAB(int a, int b) {
                a = a+b;
                b = a-b;
                a = a-b;
                System.out.println(a);
                System.out.println(b);
        }
}