There are three main objectives in this project: 1) create complex shapes by using the basic shapes through function 'def', 2) add more parameters to function such as 'side' and 'scale', and most importantly 3) create my own library and functions inside it, then import those functions to a different python file in order to draw a complex scene.  The key to success in this project was to make sure my basic and complex shapes can be drawn in any place and scale.  Again, adding parameters to the functions was essential to succesfully drawing the shapes.


Basic Shapes:

My basic shapes are semi-circle and right triangle.  As the instructions required the basic shapes to have some parameters, I made sure that my semi-circles and right triangles can be drawn at x&y location with a given side.  The command below allowed me to control the coordinates.

The images below are my own basic shapes and the block shape, which I used extensively for my aggregate shapes.

One thing to note about the right triangle is that I actually imported 'math' library in order to use a command, which calculates square root of some values.  Although it is quite obvious, the reason I wanted to use command for square-root was that I needed to draw hypothenuse by using the Pythagorean theorem.  Below is a snippet of the command.

In order to control the size of my basic shapes, I added a parameter like this, .  Below is the image of the basic shapes drawn at random places, using the random loop control.

(required picture 1).

With these basic shapes, I am going to draw two shapes that are related to space or space travel.  My aggregate shapes are rockets, launch pad, and spaceships.  Before I show the image of those shapes, I would like to talk about how I managed to put together basic shapes to create aggregate ones.  First, I had to sketch the shapes and calculate the orientations of turtle and the scale of which the sides need to increase or decrease.  Below is the snippet.  In the end, I just had to try different orientations and scales multiple times.


Below is the image of my aggregate shapes draw randomly in different locations and sizes.



Before I start to draw my space scenes using the aggregate shapes above, I also created a star shape by using for loop command. 

Although it looks really simply, I had to think about how I could shift the angle by same amount eight times.  The snippet is the answer..  Because I needed to make each line come back to original line and then turn right by 45 degrees, I used goto and included i within the angle command.

Now I am going to draw my space1, which is going to be a scene of a rocket getting to be launched.  Below is the image.

.  Although the distance between the stars and rockets is unrealistic, I tried to put them apart as far as possible by using random.randint command and certain integer ranges.  One pair of rocket and launch pad seems thicker because I added a parameter pensize.


For the second scene, we are now in space with stars and space ships.  Again, I used random loop control in order to draw the shapes in different locations.


One very important thing to note about the below snippet is the name of command,  shapelib is the name of my python file in which I wrote codes for star, spaceship, and other shapes.  If I import the library 'shapelib' to, then I am able to use the codes of the shapes from shapelib inside

It is very easy to do so..



1) I created another quasi complex shape using the basic shapes: satellite.  Compared to drawing rocket, launch pad, and space-ship, writing codes for satellite was more difficult because some shapes were not touching other shapes.  Again, calculating the heading of turtle and increment/decrement in scale was essential.


2) Because I wanted just more than stars as background ingredients for space, I wanted to draw blackhole.  The end-result does not like real blackhole, but it uses loop control function and creates an interesting image.  At first, I simply made a line drawing bigger circles, which I expected to illustrate a sort sucking-hole image.  But it did not.  Thus, I switched to using one of my basic shapes, semi-circle, and made it rotate around its starting point by 10 degrees 36 times.(36*10=360 degrees).  This result looked a lot better, so I included in my extension.

.  Doesn't the black circle in the center look like it's absorbing the surroundings?


3) I already mentioned using random.randint command.  One advantage of this random command is that I can now set different ranges for different parameters.  This can be useful when setting different locations/ranges for different shapes.


4&5) In order to add more parameters and use other turtle properties, I simply had to edit my original codes for aggregate shapes.  

For a tip, once the number of parameter starts to increase, it becomes easier to forget to include them when calling the functions.

Regarding using color randomly, I actually borrowed the codes from this website:  The idea is quite simply.  Create a variable 'color' which has different values, i.e. colors.  Then use random.choice(color), which is one of the random packages, to draw with different colors.  Although I am not sure whether this is the most efficiency way to paint in different colors, this is surely one way to do so.  


6) Below is the final image, which uses almost all of my shapes: stars, space-ships, satellites, blackholes, and rockets with different colors and pen width at different locations.

.  I made the background black to make it look more like space.


What I learned:

I became more familiar with adding parameters to function and importing different library to use for drawing shapes.  One thing to remember for myself regarding drawing the aggregate shapes is that I must draw a sketch first and need to know how I would like to manipulate the scales.  Another important lesson is that I can build further complex shapes by using basic shapes.  In a broader sense, I can use different functions to create further complex function.  


People I worked with:


I had help from Professor Skrien & Eaton, TAs during the weekends.  I also used a code from a website to draw in different colors randomly.