
In this project, you will practice using functions to make scenes with more hierarchical complexity. So far, you have made scenes as collections of compound shapes, which are collections of simple shapes. Now you will take this one step further and create a museum scene that will incorporate miniature versions of your previous scenes in it (scenes within scenes)!
The goals of this project are:
Extension points are awarded for complex scenes, especially those that show me that you can integrate concepts from lecture into making your scenes and take things to the next level!
better_shapelib.pybetter_shapelib.pybetter_shapelib.pybetter_shapelib.py
museum.pybetter_shapelib.pyImport turtle and random. Copy-and-paste in your goto and rectangle functions from lab.
mondrian functionCopy-and-paste main from lab into better_shapelib.py. Rename it mondrian.
Add an keyword argument named numRectangles that has some default value. Have numRectangles control the number of iterations your loop runs, replacing the command-line argument (from sys.argv). You will be able to still control this with command-line arguments if you would like; you can add it back in later.
The function signature so far should be:
def mondrian(numRectangles=<int of your choice>): '''Fill me in'''
Test out your mondrian function to make sure that it works. This should be done by adding the following to the bottom of better_shapelib.py:
if __name__== '__main__': mondrian()
Notes:
exitonclick and probably turtle.tracer(False).better_shapelib.py to make sure they work.mondrian (and all other files and functions), follow the code organization best practices (e.g. make docstrings, use inline comments, etc.). This will affect your grade!mondrianImagine that the Mondrian that is drawn by your mondrian function is "a compound shape". Add required position and scale parameters:
def mondrian(x, y, s, numRectangles=<int of your choice>): '''Fill me in'''
Make the position parameters adjust where on the canvas the Mondrian is drawn and the scale parameter adjust its size. Test out drawing your "Mondrian scene" a few times in different positions at different scales. You should get something that looks like this:

Hint: It might help to think of the random positions of the Mondrian rectangles as offsets from the (x, y) that you pass into the mondrian function.
better_shapelib.pyThink ahead: you will be making miniature versions of one of your scenes from last week's project and placing them in a "meta" museum scene (e.g. as paintings, statues, rug patterns, views outside windows, etc.). So you probably will want to pick shapes that are needed to draw your scene.
Things to do for each simple shape function you paste into better_shapelib.py:
fill keyword argument and integrate it into your function.color keyword argument and integrate it into your function.better_shapelib.pyThey should rely on the simple shapes from Task 3.
fill keyword argument and integrate it into your function.color keyword argument (maybe more if you need to control more than one color) and integrate it into your function.better_shapelib.pyOr create a new scene if you wish. Add position and scale parameters so that the function signature looks something like mondrian (you might need more parameters):
def myScene(x, y, s): '''docstring''' # your code here
Make it so that your function uses the scale s and position (x, y) parameters like usual.
Reminders:
(x, y), convert the remaining hard-coded positions into offsets from (x, y).turtle.left(30)).turtle.forward(100) turtle.forward(s*100)Call your scene function at least three times (in main code — i.e. indented in if __name__== '__main__':). Take a screenshot like you did for the Mondrian above. This is Required Image 2 to be included in your project report.
museum.pyIn museum.py, import your better shape library. You probably want to rename the import to save you typing:
import better_shapelib as bsl
Create a function called museum in museum.py that is a new scene that looks like a museum that includes:
You should use each of the above scenes in the museum at least once (e.g. the view outside a window, paintings, sculptures, wall or rug patterns, etc.). Draw additional simple and compound shapes to make it look like an actual museum. Be creative!
Running python3 museum.py should draw your museum scene. Take a screenshot. This is Required Image 3 to be included in your project report.
Updated note: Completing this section is optional. Doing so counts toward extensions.
It does not have to be fancy. For example, the command-line argument could control the color of an object or the time of day.
Take screenshots of both versions of your museum scene.
Important: Both your report AND museum docstrings should make it clear to me how I should run your museum.py to generate your museum scene versions. For example:
def museum(): '''Draws my museum scene. Requires a command-line argument to change the color of a painting. The following makes it red: python3 museum.py red The following makes it blue python3 museum.py blue '''
In order to grade your project, we need to be able to run your code and get the same results as you do! Here is a summary of the expected outputs from each of the source code files that you created:
python3 lab3.py: Draws your Mondrian from labpython3 better_shapelib.py: Draws your scene updated from Project 2 (or a new one if you decided to do that).python3 museum.py: Draws your museum (scene of scenes).Congratulations on completing the core tasks! If your code and report meet the above expectations, you’ve already earned up to 26/30 points for this project.
The remaining 4/30 are a chance for you to earn credit for exploring parts of this project and digging deeper to express your creativity! This is entirely optional; 26/30 is a B and is a perfectly respectable place to stop. Extensions are open-ended and exist to compliment the structured core project. Explore and learn something new that interests you! Concentrating your energy on 1-2 "deep" extensions that challenge you will earn you more points than many small, "shallow" extensions.
You can pick your own topics that interest you. Here are a few examples:
sys.argv in museum.py and the museum function.To turn in your project, make sure you do all of the following:
Lab03 folder inside Project03).Project03 folder contains your code, report, and any other required files.Project03 to your Google Drive folder that is associated with this course.