# Cole LaPlante Project 2

## Abstract:

This project was designed to make us practice using aggregate functions to create designs. These designs were inspired by Sol LeWitt, an artist famous for making instructions to create his artwork. We were also supposed to practice making these designs more complex by changing elements of them. Furthermore, we were supposed to learn how to organize our code properly when creating complex pictures.

I imported shapelib into the main.py file I created, and I added scene1() and input() at the bottom.

I used a function called stars, a function called block, and a function called circle.

• def stars (x,y,scale):
• def block (x,y,w,h):
• def circle( x, y, radius):

I started out with simple shapes that I assumed could be made into some type of picture (I was planning on making many trees with stars in the sky). However, I only ended up using the circle and block functions, because I had to completely recreate the star function when I wanted it to be filled with color. I was able to use it at the end when I was randomizing the colors in my scene with trees (below).

As can be seen by the picture I created, things didn't fully go to plan. I quickly realized that in order to fill the shapes after the first without re-filling as a new color, I would need to create a new function that included the first, which was to draw the smaller star, but then it would have to go to where the bigger star begins, draw it, and then I would have a fillable shape. However, my code seemed perfect, but simply using t.goto(x*scale,y*scale) to begin the bigger star threw off the whole picture a lot more than I eventually made it. Every bigger star was to the left more than it should have been. So, for the bigger star, I used t.goto((x*scale)+2,y*scale) to move it to the right. It looks a lot better, but the paint begins to leave a slight a gap in between colors, which I couldn't figure out how to get rid of. I'm not sure where my understanding of what *scale does actually is at this point. My scene1() function could be improved later on.

I used a few functions that I found on python.org to find out how to fill in colors and change the pen color.

I created a scene with the initial shapes that I used, but in order to make it interesting, I randomized the pen color on each shape. To do this, I copied each function to create new ones with color randomization (colorBlock, colorStars, colorCircle), and then I did some internet research, found a python forum link that showed me how to randomize colors.

import random
colors = ["red","blue","green","violet","pink","orange"]

Then I added the parameter "colors" in each new shape function. Before each shape began moving the turtle I added:

t.pencolor(random.choice(colors))

I enjoyed making this scene, and I think it came out nicely.

## Extensions:

### Extension 1:

Star design with thick lines and random pen/fill colors

I took the scene1 function that I used before but I made serious edits to it. I used the same color randomizer I used before, but I was wondering about how this design would look with no fill colors and just the thick lines. I found the method to change the thickness of my lines on the python forum. This design came out better than the first star design, but overall they both could be much better.

## Questions:

1. Breaking a scene into pieces allows you to add complexity to certain aspects of the scene. You can change the scale of everything, the color of some things, etc. If you had one long function, it would be much harder to make the designs that much more interesting.
2. A for loop is useful in making complex images made out of a few lines or small simple shapes, because you can repeat the same lines of code however many times you want to.
3. The difference is that when you use "from turtle import as *" you don't have to use "turtle." to tell python that you are using code that you just imported from turtle. However, I simply used "import turtle as t" so that all I needed before each turtle command was "t." When you use the first example I believe turtle commands simply become part of the global symbol table.
4. I chose the picture I pasted above for inspiration. I feel like I came close to recreating it and that Is why I chose it. I didn't really know how to recreate it, but I thought I could figure it out.

## Conclusion:

Overall, I learned quite a few more methods that I can use in turtle as well as python in general. But I also was able to learn a lot about function parameters, and how I can manipulate them to create a picture I like. I also got more practice with using aggregate functions and organizing my code well.

## Acknowledgements:

https://docs.python.org/3/library/turtle.html#turtle.colormode

https://docs.python.org/2/library/turtle.html

Labels