Short assignment: Sketch

The cs1 graphics library contains functions that draw shapes to a window on your computer. To get you comfortable with cs1lib, we are sending you to kindergarten - that time of blocks, snack time, glue (which sometimes was snack time), and most relevantly, drawing.

You will create an illustration inspired by the cover of your favorite picture book. You can see an example of what you should aim for here, inspired by Dr. Seuss’s Green Eggs and Ham:

Green Eggs and Ham

You may pick any children’s book cover you like, or if you are artistically inclined, create your own (representational) art. Looking for inspiration? Here are a few of my favorites from 2011.

The code behind the example draws:

As our example shows, your drawing does not need to be beautiful - although you’re free to make it so! However, it should have a minimum of:

We are particularly interested in your code. You should write and use at least three functions that set colors. For example, my code had:

You should write and use one function that sets the background. Mine was make_background_red. (Hint: The body of this function was two lines, the second of which was a call to clear.) You also need a function that makes the entire drawing. I had a function ‘draw_green_eggs_and_ham’. It is the parameterless function called by start_graphics.

Most of the action for my code was in the draw_green_eggs_and_ham function. I found it to be a really good idea to define some variables for the locations of various points in the fork, and then I could do some simple arithmetic to draw the tines. But I’ll leave it to you how to write the code to draw everything, as long as you define and use the functions correctly. If you define other functions, you are free to have them take parameters if you like.

The stroke color is the color that outlines of filled objects (such as circles, ellipses, triangles, and rectangles) are drawn in. It’s also the color that lines are drawn in.

Remember that style counts – a lot! To write well-styled code:

Refer to lecture notes and the cs1lib library documentation if you get stuck, available as an appendix off of the Text section of the course web page.

###Helpful Hints:

Have fun (and don’t eat the glue)!

What to turn in on Canvas

There are two things you need to turn in.

  1. drawing.py (or whatever you called the program you wrote to draw your picture.)

  2. A screenshot of your drawing, in whatever popular image format you prefer (.tiff, .png, .bmp, .jpg, etc).

Please remember in all assignments that editing the output of the program before submitting it is a violation of the Academic Honor Principle. Make sure that the picture you turn in comes from the program that you turn in. If you make any change to the code, no matter how insignificant you think it might be, rerun your program to produce a new picture!!

Honor Principle

The consequences of violating the Honor Principle can be severe. Please always keep in mind the word and spirit of the Honor Principle.