Docsity

CPSC 121 Fall 2012 Lecture Notes: Turtle Graphics and Function Definitions, Study notes of Computer Science

Partial preview of the text

Download CPSC 121 Fall 2012 Lecture Notes: Turtle Graphics and Function Definitions and more Study notes Computer Science in PDF only on Docsity!

Today ...

  • More practice with Turtle

Homework

  • HW 2 due / HW 3 out

Exercise: Drawing Segments

In HW 3, lets say we want to draw the character ‘7’:

  1. Call the draw char 3(p, l, x, y) function
  2. This calls the draw segment a(p, l, x, y), draw segment b(p, l, x, y), and draw segment c(p, l, x, y) functions
  3. These in turn call draw horiz segment(p, l, x 1 , y 1 ), draw vert segment(p, l, x 2 , y 2 ), and draw vert segment(p, l, x 3 , y 3 )

In pairs, implement the draw horiz segment(p, l, x, y) function ...

  • Draw the “lozenge” in an imaginary rectangle with height 20 and length given by l
  • The lower left-hand corner of the rectangle is the coordinate (x, y)
  • Assume the “corners” are 10 x 10

If you finish early, implement draw vert segment(p, l, x, y)

  • with height l and width is 20

If you are done, fill your segments with a color: p.begin_fill()

draw the segment ...

p.fillcolor("gray") p.end_fill()

To complete the lab:

  • Show me that your segment works
  • Print and hand in your source file
  • Be sure your names are on the file