Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package cz.czechitas.beginnerjava.homework.practice;
- import java.awt.Color;
- import org.teachingextensions.logo.Turtle;
- import org.teachingextensions.logo.utils.ColorUtils.PenColor;
- public class SpiralShow {
- public static void main(String[] args) {
- SpiralShow myApp = new SpiralShow();
- myApp.run();
- }
- // #2 - Set the turtle to some initial position. E.g., X = 300, Y = 200.
- Turtle turtle = new Turtle();
- public void run() {
- turtle.show();
- turtle.setSpeed(10);
- turtle.setPenColor(PenColor.PINK);
- turtle.setPenWidth(2);
- turtle.setX(300);
- turtle.setY(200);
- drawSpirals(150,250,PenColor.green);
- drawSpirals(400,350,PenColor.BLUE);
- drawSpirals(600,150,PenColor.YELLOW);
- drawSpirals(300,110,PenColor.MAGENTA);
- }
- public void drawSpirals (int x, int y, Color paint) {
- turtle.setX(x);
- turtle.setY(y);
- turtle.setPenColor(paint);
- int lenght;
- lenght = 10;
- int i;
- for (i = 0; i < 50; i++) {
- turtle.move(lenght);
- turtle.turn(90);
- lenght = lenght + 5;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement