CSC 226

CSC 226 logo

Software Design and Implementation


A4: Turtle Houses

Assignment A4 should be complete individually.
In this assignment, students will learn about color and screen coordinates, in addition to gaining practice with turtle graphics.

Image Colors

Images displayed on a screen use light for the display.  Any three colors (or frequencies) of light that produce white light when combined with full intensity are called primary colors of light. The most commonly used set of primary colors of light is the set Red (R), Green (G), and Blue (B).  Using a term borrowed from neuroscience, each color is typically called a color channel.

The following is a widget we created for your exploration of color channels.  Try various RGB color channel values between 0 and 255:

More on Turtle Graphics

A summary of all turtle methods for Python 2.7 can be found at: http://docs.python.org/2.7/library/turtle.html

Some turtle methods which may be particularly useful for this assignment assuming that myturtle has been instantiated as a turtle.
  • myturtle.begin_fill(), myturtle.end_fill() # The figure drawn between the two fill commands is filled with the present color setting.
  • myturtle.circle(radius) # Draws a circle of the indicated radius. Assuming the radius is positive, the circle is drawn tangent to the direction of myturtle in a clockwise direction.
  • myturtle.clear() # Erase everything written by myturtle.
  • myturtle.fillcolor(r, g, b), myturtle.fillcolor(s) # Set the color for filling figures--see widget above for exporation. In fillcolor(r,g,b), each
    argument is a floating point number between 0.0-1.0; the fraction of red, the fraction of green, and the fraction of blue. In fillcolor(s) the argument is a string indicating a color by name or by its hexadecimal code, e.g., “green”, “red”, “#6600FF”. Arguments are the same for pencolor.
  • myturtle.forward(distance), myturtle.backward(distance) # Move myturtle forward or backward the amount of distance indicated. Oriented on the direction myturtle is facing. Draws a line if myturtle is down, not if myturtle is up.
  • myturtle.pencolor(r,g,b), myturtle.pencolor(s) # Set the color that myturtle. In pencolor(r,g,b), each
    argument is a floating point number between 0.0-1.0; the fraction of red, the fraction of green and the fraction of blue. In pencolor(s) the argument is a string indicating a color by name or by its hexadecimal code, e.g., “green”, “red”, “#6600FF”.
  • myturtle.pensize(width) # Set the line thickness to width.
  • myturtle.right(degrees), myturtle.left(degrees) # Turn the given direction oriented by myturtle.
  • myturtle.setpos(x,y) # Move myturtle to the specified point, drawing a line along the way if myturtle is down, and not drawing if myturtle is up.
  • myturtle.shape("circle") # May use the following polygon shapes: "arrow", "circle", "classic", "square", "triangle", "turtle"
  • myturtle.shapesize(stretch_wid=2, stretch_len=None, outline=None), myturtle.turtlesize(stretch_wid=2, stretch_len=None, outline=None) # myturtle will be displayed stretched according to its stretchfactors: stretch_wid is perpendicular to its orientation, stretch_len is in the direction of its orientation, outline determines the width of the shapes’s outline.
  • myturtle.stamp() # Stamp a copy of the turtle shape onto the canvas at the current turtle position.
  • myturtle.write(string) # Write a string starting at the present myturtle point.
  • myturtle.up(), myturtle.down(), myturtle.penup(), myturtle.pendown(), # Set myturtle state to be up (for not drawing) or down (for drawing)
Rather than give you example files this time, we don't want to influence your designs, so would like you to create this program completely on a blank

The instructions

This assignment should be completed individually, but consulting with each other is fine. 
In this assignment, you will draw a house using turtle graphics. 

Make sure that your house:
  • Has at least one thing which looks like some sort of building.
  • Is set against a background which is not white.
  • Has some embellishments such as windows, text, trees, flowers in front of the house or something--these are not all required--they are just suggestions.
  • Has at least one interesting detail such a intricate windows, smoke out of the chimney, etc.
  • Uses creativity (such as the use of color, an intricate shape, a cool design…)
  • Be sure to include our standard header at the top of your program with name, username, assignment number, purpose and acknowledgements.
  • Also, please be sure to include comments for the sections in your code which draw the different shapes.

Note that submitted files with incorrect filenames may not receive full credit because it makes grading more difficult for us and the TAs, so please check filenames carefully!

Also, be sure to read Chapter 4: Functions of How to Think Like a Computer Scientist in preparation for a quiz which will take place at the beginning of our next class. 

Note that this assignment was adapted from "http://www.garfieldcs.com/2012/03/python-turtle-house-practice/".

Copyright © 2014 | http://faculty.berea.edu/pearcej/CSC226/