import java.awt.Color;
import sk.upjs.jpaz2.Turtle;
public class MojaKorytnacka extends Turtle {
public void bodkyVKruhu(int pocet, double polomer) {
this.penUp();
double pocX = this.getX();
for (int i = 0; i < pocet; i++) {
this.turn(Math.random() * 360);
this.step(polomer);
if (this.getX() < pocX) {
this.setFillColor(Color.red);
} else {
this.setFillColor(Color.green);
}
this.dot(5);
this.step(-polomer);
}
}
public void zahada() {
for (int i = 0; i < 256; i++) {
Color c = new Color(i, 100, 100);
this.setPenColor(c);
this.setPosition(i, 0);
this.moveTo(i, 150);
}
}
public void nahodnaFarba() {
int r = (int) (Math.random() * 256);
int g = (int) (Math.random() * 256);
int b = (int) (Math.random() * 256);
Color nahodnaFarba = new Color(r, g, b);
this.setPenColor(nahodnaFarba);
}
public void nahodnaFarbaVyplne() {
int r = (int) (Math.random() * 256);
int g = (int) (Math.random() * 256);
int b = (int) (Math.random() * 256);
Color nahodnaFarba = new Color(r, g, b);
this.setFillColor(nahodnaFarba);
}
public double sustredneKruhy(double polomer) {
int poradie = 1;
double obsah = 0;
while (polomer > 1) {
if (poradie % 3 == 0) {
this.setFillColor(Color.gray);
}
if (poradie % 3 == 1) {
this.setFillColor(Color.red);
}
if (poradie % 3 == 2) {
this.setFillColor(Color.blue);
}
this.dot(polomer);
obsah = obsah + polomer * polomer * Math.PI;
poradie++;
polomer = polomer * 0.8;
}
// korytnacka zakrici to co je v premennej obsah
return obsah;
}
public long mocnina(int n, int k) {
long displej = 1;
for (int i = 0; i < k; i++) {
displej = displej * n;
}
return displej;
}
}