Today’s Plan

Today’s Groups

GroupMembers
AEnayet, Danielle, Jane
BTalia, Sanie, Amber
CJonathan, Sachi, Dorothy, Gabriel
DBateel, Jennifer, Kim

Homework Review

Today’s Learning Objectives

Assignment

Keep Sketching!

Suggestions:

Challenge: Animal Face

Using turtle graphics, create an intricate portrait of an animal. Begin by choosing an animal. Look a photo references of your animal and note interesting details, textures, patterns, and features. How can you translate those details into your sketch. Create you sketch primarily using turtle graphics techniques.

Logo and Turtle Graphics

Logo is a computer programming language, created in 1967 at the (now) MIT Media Lab to explore how programming can help children learn critical thinking and problem solving. One of the creators of Logo, Seymour Papert, wrote the book Mindstorms which discusses logo and its goals.

One of the ideas introduced in Logo was "turtle graphics". In Logo one can issue commands like left to turn and forward to move. These commands are carried out by a robotic or on-screen "turtle". The turtle can draw a line, tracing its path and producing interesting drawings.

Logo’s use of turtles allows students make a strong association between what happens in the program and how they move their own bodies in the real world. Papert called this “body-syntonic” learning.

Our Simple Turtle

I’ve created a basic implementation of a turtle for you to use this week.

Grab the code here.

Comp Form Turtle API

myTurtle = new Turtle(x, y)

turtle constructor, creates a turtle object takes optional x, y starting coordinates (default is center of sketch)

myTurtle.moveForward(distance)

moves the turtle along its current bearing, drawing a line if pen is down

myTurtle.moveBackward(distance)

moves the turtle backward from its current bearing, drawing a line if pen is down

myTurtle.moveTo(x, y)

instantly transports the turtle to the provided x, y location, drawing a line if pen is down

myTurtle.turnRight(angleDegrees)

rotates the turtle’s bearing clockwise by the provided angle in degrees

myTurtle.turnLeft(angleDegrees)

rotates the turtle’s bearing counter-clockwise by the provided angle in degrees

myTurtle.turnTo(angleDegrees)

changes the turtle’s bearing to the provided angle in degrees

myTurtle.penUp()

tells the turtle to move without drawing

myTurtle.penDown()

tells the turtle to draw a line when it moves

myTurtle.image(image, width, height)

draws and image centered on the turtle’s current location and aligned with the turtle’s rotation

myTurtle.pushState()

records the turtle’s current state (position, bearing, etc.) to a stack so that changes can be undone easily

myTurtle.popState()

restores the turtle’s state to the top recorded state on the stack

Turtle Examples

Turtle Square Example

Turtle Triangle Example

Turtle Multiple Triangles Example

Turtle Spiralgraph Example

In-class Challenge

Explore using p5’s pixel manipulation functions by modifying the scripts above. Work through the following challenges in order. Don’t skip any.

Modify the Triangle Example

  1. Draw a Pentagon.
  2. Draw an Octagon.
  3. Draw a Circle.
  4. Draw a Circle with a dashed line. Tip: penUp() + penDown()

Modify the Multiple Triangles Example

  1. Draw each triangle with different colors.
  2. Change the triangle function to draw squares.
  3. Remove the .moveTo() commands.
  4. Change the .turnTo() commands to turnLeft(60).

Style Tip: If you change what a function does, you should change its name as well. Did you change the function name in 6?

Modify the Spiralgraph Example

  1. Change the moveForward() parameter to i * 3.
  2. Center the result of 11.
  3. Comment out the noLoop()
  4. Change the turnRight() parameter to 175 + frameCount.

Challenging Challenges

  1. Start with the original Triangle Example. Change it to draw a Spiral.
  2. Draw two spirals. One Red, one Blue. They should spiral inside each other.
  3. Using a loop, draw 10 concentric triangles.
  4. Draw this: challenge_1.png

Challenge Self Assessment

After you work with Turtle Graphics this week, you should have a solid grasp on the basics. Consider redoing the challenges above to see how solid your understanding is.

TimeComment
< 12 in 20 minutesYou need to put in some extra work to strengthen your programming understanding.
12 in 20 minutesGood.
16 in 30 minutesGreat.
16 in 20 minutesHot Dang!

Study Examples

Turtle + Images

Turtle Push + Pop

Turtle Recursive Tree