/* 1. Paste your methods from the Christmas Tree Recipe here. */ void drawTreeBody() { // 8. Change the color of the line the tortoise draws to forest green Tortoise.setSpeed(10); Tortoise.setPenColor(Colors.Greens.Chartreuse); // 1. Make a variable for turnAmount and set it to 175 int turnAmount = 175; // 2. Start the Tortoise facing to the right Tortoise.turn(90); // 5. Repeat steps 3 through 11, 11 times for (int i = 0; i < 11; i++) { // 3. Move the tortoise the width of the tree Tortoise.move(treeWidth); // 4. Turn the tortoise the current turnAmount to the right Tortoise.turn(turnAmount); // 6. Set the treeWidth to the current treeWidth times the scale treeWidth = treeWidth * scale; // 7. Move the tortoise the width of a tree again Tortoise.move(treeWidth); // 9. Turn the tortoise the current turn amount to the LEFT Tortoise.turn(-turnAmount); // 10. Set the treeWidth to the current treeWidth times the scale again treeWidth = treeWidth * scale; // 11. Decrease turnAmount by 1 turnAmount--; } }
private static void drawStairRoof() { Tortoise.turn(90); Tortoise.move(30); Tortoise.turn(90); Tortoise.move(30); Tortoise.turn(90); }
private static void drawPointRoof() { Tortoise.turn(45); Tortoise.move(10); Tortoise.turn(90); Tortoise.move(10); Tortoise.turn(45); // Tortoise.move(130); }
public static void drawLowerBranches(int branchLength) { Tortoise.turn(30); drawShorterBranches(branchLength); Tortoise.turn(-60); drawShorterBranches(branchLength); Tortoise.turn(30); adjustColor(branchLength); Tortoise.move(-branchLength); }
private static void drawhousewithSlantyRoof(int height) { Tortoise.setPenColor(PenColors.Grays.LightGray); Tortoise.move(height); drawSlantyRoof(); // Tortoise.move(120); Tortoise.turn(-90); Tortoise.move(20); Tortoise.turn(-90); }
private static void drawhousewithPointRoof(int height) { Tortoise.setPenColor(PenColors.Grays.LightGray); Tortoise.move(height); drawPointRoof(); Tortoise.turn(360); Tortoise.move(130); Tortoise.turn(-90); Tortoise.move(10); }
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(); }
void drawStar() { // * Optional: Draw a red star on top of the tree. Hint: 144 degrees makes a star. Tortoise.setPenColor(Colors.Reds.IndianRed); for (int i = 0; i < 5; i++) { Tortoise.move(15); Tortoise.turn(144); } }
void drawStar() { // * Optional: Draw a red star on top of the tree. Hint: 144 degrees makes a star. Tortoise.setAnimal(Animals.Unicorn); for (int i = 0; i < 5; i++) { Tortoise.setPenColor(Colors.Reds.OrangeRed); Tortoise.setSpeed(10); Tortoise.move(20); Tortoise.turn(144); } }
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); } }
private static void makeTortoiseBody() { Tortoise.turn(-90); Tortoise.move(255); Tortoise.turn(135); Tortoise.move(135); Tortoise.turn(45); Tortoise.move(120); Tortoise.turn(45); Tortoise.move(70); Tortoise.turn(-90); Tortoise.move(35); Tortoise.turn(45); Tortoise.move(60); Tortoise.turn(65); Tortoise.move(50); Tortoise.turn(115); Tortoise.move(65); Tortoise.turn(-25); Tortoise.move(65); }
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); } }
/** * 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"); }
public static void main(String[] args) { int turn = 90; Tortoise.move(200); Tortoise.turn(turn); Tortoise.move(100); Tortoise.turn(turn); Tortoise.move(200); Tortoise.turn(turn); Tortoise.move(200); Tortoise.turn(turn); Tortoise.move(200); Tortoise.turn(turn); Tortoise.move(200); Tortoise.turn(turn); Tortoise.move(100); Tortoise.turn(turn); Tortoise.move(200); }
private static void makeTortoiseLeg() { for (int i = 0; i < 4; i++) { Tortoise.move(35); Tortoise.turn(90); } }
private static void drawSlantyRoof() { Tortoise.turn(45); Tortoise.move(30); Tortoise.turn(135); Tortoise.move(160); }
private static void drawTriangle() { for (int i = 0; i < 6; i++) { Tortoise.move(length); Tortoise.turn(3600 / 30); } }