
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 scene within a scene that will incorporate miniature versions of your previous scenes in it, inspired by the Surrealist Art Movement.
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.pyImport turtle and random. Copy-and-paste in your goto and rectangle functions from lab.
mondrian functionCopy-and-paste your main function from lab into better_shapelib.py. Rename it mondrian.
Add an keyword argument named numRectangles that has some default value. 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) (remember: if you turn animations off, call turtle.update() before exitonclick to make sure the canvas shows all your shapes).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. Make the position parameters adjust where on the canvas the Mondrian is drawn and the scale parameter adjust its size.
def mondrian(x, y, s, numRectangles=<int of your choice>): '''Fill me in'''
Write a mondrian_test function which draws your mondrian function a few times in different positions at different scales. You should get something that looks like this:

Take a screenshot. This is Required Image 1 to be included in your project report. Do NOT delete your mondrian or mondrian_test function, they are part of your project grade.
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.py and update them
Think ahead: you will be creating a scene where an out of place object will be repeated all over last week's scene. You will want to pick shapes that are needed to draw your new object. Look at artwork from the Surrealist Art Movement to see examples of incongruent repetition like Golconda or Les valeurs personnelles by René Magritte.
Things to do for each simple shape function you paste into better_shapelib.py:
fill keyword argument and integrate it into your function, include a default value.color keyword argument and integrate it into your function, include a default value.better_shapelib.py
It should rely on the simple shapes from above.
x and y keyword arguments and integrate them into your function to control the position the compound shape is placed.s keyword argument and integrate it into your function to control the scale of the compound shape.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.magritte function to randomly draw your new compound shape everywheremondrian function and rename it magritte. rectangle function call with a call to your new compound shape.Test out drawing your "Magritte" image a few times in different positions at different scales. Write a magritte_test function which draws your magritte function a few times in different positions at different scales.
Take a screenshot of the image your magritte_test produces. This is Required Image 2 to be included in your project report.
Choose an artist or artwork from the Surrealist Art Movement for inspiration. For example, can you use this task to create a scene within a scene with disjointed or conflicting concepts?
scene1 function from Project 2.shapelib.py to better_shapelib.py that haven't been copied over yet. scene1 function to call the local functions, making any necessary updates to parameters. scene1 function to call the magritte function. Set the position and size parameters so that it only covers a portion of the scene.Call only the scene1 function in main code — i.e. indented in if __name__== '__main__':. Run your code and take a screenshot. This is Required Image 3 to be included in your project report.
better_shapelib.pydef scene1(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)In sureal.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 sureal in sureal.py that draws your scene1 scene at least 3 times in different locations at different sizes.
Call your sureal function in main code — i.e. indented in if __name__== '__main__':. Take a screenshot like you did for the Mondrian above. This is Required Image 4 to be included in your project report.
In your report section called Art Reflection discuss which compositions/artists inspired you and what aspects of the compositions you emulated.
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 better_shapelib.py: Draws your scene updated from Project 2 with a new compound object randomly placed multiple times at random sizes.
goto, mondrian, mondrian_test, magritte, magritte_test, scene1python3 sureal.py: Draws your sureal scene in 3 different places at different sizes.
surreal function.Congratulations on completing the core tasks! Between the code that you’ve already written and the report that you write, you’ve already earned up to 26/30 points for this project. If you turn it in by the first deadline that's 27/30 points.
The remaining 3/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; 27/30 is an A- 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 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:
To get credit for your extensions, you must document them in your report. For each extension this includes:
To turn in your project, make sure you do all of the following:
hewolfe_Project3.zip.© 2021 Hannen Wolfe and Oliver Layton