Fundamentals of Computer Science I: Media Computing (CS151.02 2007F)

Laboratory: Drawing Smiley Faces

This lab is also available in PDF.

Summary: In this laboratory, you will begin to study algorithms as you explore various techniques for describing images.

Contents:

Introduction

As you will learn throughout the semester (and will be told the first day of class), one of the primary activities computer scientists do is to write clear and unambiguous instructions for a variety of tasks. In writing these instructions, it is essential that you understand what the device or person for which you are writing instructions knows.

To get you accustomed to writing instructions, we'll start with a simple task. Your goal is to teach me how to draw a traditional yellow smiley face on the white board. (If you don't know what a Smiley Face looks like, there's a good example at http://en.wikipedia.org/wiki/Image:Smiley.svg.)

To make it a bit more interesting, different groups will be limited to different sets of basic instructions to use to give instructions.

Preparation

When you entered the room (or soon thereafter), you received a colored sticker with a smiley face on it. Find two other people with the same color sticker and sit together. If we don't have an exact multiple of three in the class, feel free to form groups of four or two, as necessary. If you are color blind or color deficient, please ask a neighbor to identify the color on your sticker and to help you find someone with the same color sticker.

Once you have formed a group, read through all of the variations below and then do the work assigned to your group.

Exercises

Orange: Simple Motions

Write instructions for drawing a smiley face.

In those instructions, you should assume that I have never previously encountered pens, whiteboards, or the like. You should also note that I have never heard of shapes, so you may not refer to things like circles or squares.

You will note that other groups can assume that I know about the Cartesian plane. You may not.

Yellow: Circles, Circles, and More Circles

Write instructions for drawing a smiley face.

In those instructions, you should assume that I only know how to draw filled-in circles, but that you can choose the color and position of the circles I draw. (I can also draw white circles, which, in effect, erases anything beneath them.) You may also assume that I know coordinates on the Cartesian plane. I draw only in opaqe ink.

In other words, the only instructions you can give me are of the form: Draw a color circle of radius R centered at X,Y. You can, however, tell me to draw a lot of circles.

Green: Drawing Through Dots

Write instructions for drawing a smiley face.

In those instructions, you should assume that I have been so corrupted by the impressionists that the primary thing I know how to do is draw a dot on the board in a specified color at a specified location.

Because it can be difficult to describe each dot individually, you may also assume that I can figure out sets of dots that meet particular criteria, so that you can give instructions like put orange dots at all positions in which the sum of the x and the y coordinates is 10 or put green dots in all positions in which the product of the x and the y coordinates is less than 20. Note that I can only put dots at positions in which the x and y coordinates are whole numbers, and that dots fill a region of one unit.

You may also assume that I can can compute functions, so that you can write things like put violet dots for at (x,x^2-5) for all x between 1 and 20.

Blue: Drawing with Robotic Turtles

Write instructions for drawing a smiley face.

In those instructions, you should assume that I am trying to draw the face on the floor, and that I am limited in my actions to:

For example, to have me draw the outline of a blue square of edge length one foot, you might tell me to

This technique for drawing mimics one of the more popular ways to teach robots how to draw, and is called turtle graphics.

You may assume that I start at the center of the area in which I plan to draw, and that I am facing North.

Reflection

 

History

 

Disclaimer: I usually create these pages on the fly, which means that I rarely proofread them and they may contain bad grammar and incorrect details. It also means that I tend to update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.

This document was generated by Siteweaver on Mon Dec 3 09:55:37 2007.
The source to the document was last modified on Fri Aug 31 11:15:23 2007.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2007F/Labs/smiley-lab.html.

You may wish to validate this document's HTML ; Valid CSS! ; Creative Commons License

Samuel A. Rebelsky, rebelsky@grinnell.edu

Copyright © 2007 Janet Davis, Matthew Kluber, and Samuel A. Rebelsky. (Selected materials copyright by John David Stone and Henry Walker and used by permission.) This material is based upon work partially supported by the National Science Foundation under Grant No. CCLI-0633090. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation. This work is licensed under a Creative Commons Attribution-NonCommercial 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/2.5/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.