Skip to end of metadata
Go to start of metadata


The key concepts for this project were as follows: 1) parameter and 2) user-controlled scenes.  Parameter was essential to drawing a scene within a scene as I needed to control of scale of each scene.  Through parameter, I was able to color the shapes and fill them with color.  Another key concept, user-controlled features allow users to control some aspects of my shapes or scenes by using the sys package.  I needed to incorporate this into my shape; what I ended up doing was to allow users to choose the number of stars in my scenes.

Better Shapes:

In order to fill my shapes with color, I used the if statement as the snippet shows.

What the statement is doing is that if I give value True as a parameter for my shape, then my shape will be filled with color I specified.

If I give value False, then the shape will not be filled be color..

It would not fill the block b/c I do not have a.begin_fill() and a.end_fill() at the beginning and end of my block code.



 In order to color my shapes, I simply used turtle.color() command.

My better shapes with fill and color parameter look like this:.


I added the fill and color parameters to my aggregate shapes, and they look like below.


Better Scenes:

I added parameter 'scale' to my aggregate shapes so that I could change the scale of my scenes.  Again, I was trying to control the scale because this project was about literally drawing scenes within scenes.

One thing to note about adding scale to my shapes is that I had to make sure location was not multiplied by scale.  See the snippet below.


Notice that it is side not x or y that is multiplied by scale.  If you multiply the location coordinates by scale, then your shapes or scenes will not be drawn where you want them to be.

Below is an image of my scene drawn at three different locations with three different sizes.

 (Required Image 1)

Now I am ready to nest this scene into another one.

Nested Scenes:

First, I needed to come up with a bigger scene, which would include my scene above.  I decided to draw a scene of spaceship's cockpit(call it Apollo 13).  When designing the cockpit, I made a mistake not to use my basic shapes to draw it.  It was a mistake because the basic shapes would have been much easier to fill with color.  My codes became really complicated like below.

I had to use turtle.up() several times because I wanted to fill certain parts of my scene with color.  If my scene consisted of different basic shapes, filling work could have been much simpler.

The nested image is as below.

(Required Image 2).

Now my space 2 & extension scene from my previous project are shown through windows of Apollo 13 cockpit.

User-controlled scenes:

As I wrote in the beginning, I allowed users to control the number of stars in my inside scenes by using the sys library.  See the snippet below.

.  N=50 simply means if there is no user input on terminal, python will automatically draw 50 stars.

The two images below each have 10 and 50 stars using the codes above.

(Required Image 3). (Required Image 4).  I added colors to my radar screen and buttons as well.


(1) & (2): My image actually draw two of my scenes from last week.  The one in the middle was my extension space; the side ones are my space 2 scene.  In order to include them in my encompassing scene, I simply had to calculate what scale needs to be to fit inside the cockpit windows.

I used the range()function with three arguments as well to draw the radar screen.  Although it did not come out exactly as I intended, it portrays expanding circles.

.  This basically draws 5 circles; the first circle starts with radius of 24 and increases by 3.


(3) & (4): In order to demonstrate several levels of encapsulation, I decided to draw a TV screen which would surround the scene of Apollo 13 cockpit.  One difficulty I faced was to have different colors for my scenes. The solution was to fill my scenes separately; in order words, don't change turtle's background color.

My encapsulation scene looks like below.

.  The scene is supposedly showing a TV screen, which is also showing what astronauts in Apollo 13's cockpit are seeing through the windows.  

Although I am not sure what was expected in regard to making complex scene without using complex code, I interpreted it as create another file, which imports several libraries of my function.  Here is what I did.

.  Basically, I used one command line, task5.complexScene(), to draw my encapsulation scene.  Read my import line and the libraries.



I learned to use the sys library to allow users to have some inputs in computer programs.  The fill and color parameters also made my shapes and scenes to be drawn with more flexibility.  One thing to mention is conditional 'if __name__=="__main__":.

I realized this condition is very useful when I import a library to another and repeat this process more than once.  Regarding the user-controlled feature, I wanted to incorporate it more into my shapes but found it difficult.  I think one should think ahead of user input when drawing shapes or creating computer program in general.  

For this project, I imported turtle, math, random, sys, and my own libraries that contain my shapes and scenes.  I did not use someone else's code for this project.