void drawTree() {
   drawStar();
   drawTreeBody();
   drawTreeTrunk();
   treeWidth = 15;
   Tortoise.setAngle(0);
   Tortoise.setPenWidth(treeWidth / 5);
 }
Example #2
0
 void drawTreeTrunk() {
   // 1. Move the tortoise half the width of the tree
   Tortoise.move(treeWidth / 2);
   // 2. Change the tortoise so that it is pointing straight down
   Tortoise.turn(90);
   // 4. Set the pen width to the tree width divided by 10
   Tortoise.setPenWidth(treeWidth / 10);
   // 5. Change the color of the line the tortoise draws to brown
   Tortoise.setPenColor(Colors.Browns.Chocolate);
   // 3. Move the tortoise a quarter the tree width
   Tortoise.move(treeWidth / 4);
 }
 public static void main(String[] args) {
   Tortoise.show();
   Tortoise.getBackgroundWindow().setBackground(Grays.Black);
   Tortoise.setPenWidth(20);
   Tortoise.setSpeed(10);
   for (int i = 55; i < 999999999; i++) {
     Tortoise.setPenColor(PenColors.getRandomColor());
     length = length + 1;
     drawTriangle();
     Tortoise.turn(1000000000 / 20000);
   }
 }
 /**
  * Makes a cool shape fast <div><b>Example: </b> {@code tortoise.drawShape(6,PenColors.Reds.Red,
  * 50, 20)}</div>
  *
  * @param sides the number of sides
  * @param color a snazzy line color
  * @param length the bigger the better
  * @param width make a thick line - it's cool
  */
 public static void drawShape(int sides, Color color, int length, int width) {
   Tortoise.show();
   Tortoise.setSpeed(7);
   Tortoise.getBackgroundWindow().setBackground(PenColors.Yellows.Goldenrod);
   new Text("TKP Java - Make Some Shapes!")
       .setTopLeft(225, 50)
       .addTo(Tortoise.getBackgroundWindow());
   for (int i = 0; i < sides; i++) {
     Tortoise.setPenColor(color);
     Tortoise.setPenWidth(width);
     Tortoise.move(length);
     Tortoise.turn(360 / sides);
   }
   VirtualProctor.setClassName("Grace Hopper's Class");
   VirtualProctor.setName("Jean Bartik");
 }
  void drawTreeTrunk() {
    // 1. Move the tortoise half the width of the tree
    Tortoise.setAnimal(Animals.Spider);
    Tortoise.move(treeWidth / 2);

    // 2. Change the tortoise so that it is pointing straight down
    Tortoise.setAngle(180);

    // 4. Set the pen width to the tree width divided by 10
    Tortoise.setPenWidth(treeWidth / 10);

    // 5. Change the color of the line the tortoise draws to brown
    Tortoise.setPenColor(Colors.Browns.DarkGoldenrod);

    // 3. Move the tortoise a quarter the tree width
    Tortoise.move(treeWidth / 4);
  }
 public static void drawTortoise() {
   Tortoise.show();
   Tortoise.setSpeed(9);
   Tortoise.getBackgroundWindow().setBackground(PenColors.Greens.DarkSeaGreen);
   new Text("TKP Java - It's the Tortoise!")
       .setTopLeft(200, 75)
       .addTo(Tortoise.getBackgroundWindow());
   Tortoise.setPenColor(PenColors.Greens.Green);
   Tortoise.setPenWidth(3);
   makeTortoiseBody();
   Tortoise.setPenColor(PenColors.Browns.Brown);
   Tortoise.turn(-65);
   Tortoise.makeTortoiseLeg();
   Tortoise.turn(90);
   Tortoise.move(150);
   Tortoise.turn(-90);
   Tortoise.makeTortoiseLeg();
 }
Example #7
0
  public static void main(String[] args) {

    // 3. ask the user what color they would like the tortoise to draw
    String color = JOptionPane.showInputDialog("What color do you want the pen color to be");
    // 4. use an if/else statement to set the pen color that the user
    // requested
    for (int i = 0; i < 5; ) {
      if (color.equals("Blue")) {
        Tortoise.setPenColor(Color.blue);
      }
      if (color.equals("Red")) {
        Tortoise.setPenColor(Color.red);
      }
      if (color.equals("Green")) {
        Tortoise.setPenColor(Color.green);
      }

      // 5. if the user doesn’t enter anything, choose a random color
      Colors.getRandomColor();
      // 6. put a loop around your code so that you keep asking the user for
      // more colors & drawing them

      // 2. set the pen width to 10
      Tortoise.setPenWidth(10);
      // 1. make the tortoise draw a shape (this will take more than one line
      // of code)
      Tortoise.penDown();
      Tortoise.move(100);
      Tortoise.turn(90);
      Tortoise.move(100);
      Tortoise.turn(90);
      Tortoise.move(100);
      Tortoise.turn(90);
      Tortoise.move(100);
    }
  }