CS 106 Winter 2017
Lab 05: Geometric context
Question 1 Dancers
In a series of exercises, you will use combinations of geometric context functions to draw different configurations of dancers. The goal is to do everything with geometric context functions. Every dancer will be drawn using shape( dancer, 0, 0 ), surrounded by suitable calls to pushMatrix(), popMatrix(), translate(), rotate(), and scale().
Download the provided starter code. Navigate into the L05 folder and open the Dancers sketch.
From the provided code, run the Dancers sketch. You'll see a single dancer in the centre of the sketch window:
Fill in the function drawMode1() so that it draws a 5×5 grid of dancers, as in the image below. All transformations must be based on the built-in functions translate(), rotate(), scale(), pushMatrix(), and popMatrix(). To draw each dancer, you must use shape( dancer, 0, 0 )—no other arguments to shape() are permitted here, or in any of the other problems below!
In this case, you'll want to use two nested loops, one in x and one in y (in either order). Inside the nested loops, translate, scale and draw a single dancer.
Fill in the function drawMode2() so that it draws alternating upright and upside-down dancers, with their arms all pointing to the same side of the screen. Again, make sure that every dancer is drawn using shape( dancer, 0, 0 ). Remember that you can use the call scale( 1, -1 ) (inside a pushMatrix()/ popMatrix() pair) to flip a dancer upside-down.
Fill in the function drawMode3() so that it draws a single large dancer near the middle of the sketch, with at least three smaller dancers perched on her. The smaller dancers must have their lower legs touching the large dancer, and must fit entirely in the sketch window. The image below gives one example.Unlike the other exercises in this lab, there's no "abstract" way to draw this configuration, for instance based on loops. The best solution is simply to "eyeball" it: draw the large dancer, and experiment with the scaling and translation of the smaller dancers until you're happy with the result.
Fill in the function drawMode4() so that it draws a ring of eight dancers around the centre of the sketch window, each dancer rotated symmetrically:
Fill in the function drawMode5() so that it draws a ring of eight dancers around the centre of the sketch window, all standing upright:
You don't have to create exact copies of the screenshots shown here. The important thing is to create similar patterns. You may need to experiment with different scales and translations to get something similar.
Obviously you should avoid writing functions that simply draw each dancer explicitly (e.g., 25 calls to shape() for Mode 1). When possible, use for loops to draw the dancers you need.
Save your sketch, which should be named Dancers.
When you are ready to submit, please follow these steps.
If necessary, review the Code Style Guide and use Processing's built-in auto format tool. You do not need to use the precise coding style outlined in the guide, but whatever style you use, your code must be clear, concise, consistent, and commented.
If necessary, review the How To Submit document for a reminder on how to submit to LEARN.
Make sure to include a comment at the top of all source files containing your name and student ID number.
Create a zip file called L05.zip containing the entire L05 folder and all its subfolders.
Upload L05.zip to LEARN. Remember that you can (and should!) submit as many times as you like. That way, if there's a catastrophe, you and the course staff will still have access to a recent version of your code.
If LEARN isn't working, and only if LEARN isn't working, please email your ZIP file to the course account (see the course home page for the address). In this case, you must mail your ZIP file before the deadline. Please use this only for emergencies, not "just in case". Submissions received after the deadline may receive feedback, but their marks will not count.