Project 10 (Philip Prosapio)
Skip to end of metadata
Go to start of metadata

Philip Prosapio
Spring 2010 - CS151

Note- My code for this project is in the pwprosap account on the academic server.


For this lab I had to expand upon the concept of the jitter draw style that we had made in lab and implement more types of drawing. First I needed to make a 'broken' draw style, and then I made a 'dash' draw style. These two had to be made and then implemented into shapes from last weeks project. The next task was for me to take the indoor scene from last weeks project and implement my new draw styles into the scene. And the final task had me making a new parameterized Lsystem.

Solution to Tasks

1) So the first task had me making the 'broken' draw style, all of this coding was done in the interpreter file. This code resembled our 'jitter' code from lab pretty closely, but with the major difference that a broken line was made up of two distinct line segments. In order to make the endpoints of the line segments, I needed to implement the gauss function:

  1. assign to jx the result of random.gauss(0, self.jitterSigma)
    jx = random.gauss(0, self.jitterSigma)
  2. assign to jy the result of random.gauss(0, self.jitterSigma)
    jy = random.gauss(0, self.jitterSigma)

This made it so the endpoints were randomly selected near the actual points of the shape. The picture of my jittered, broken, and normal shapes is attached and labelled picture1lab10.png .

2) For the second task, I needed to create another draw style that would make dashed figures. For this one, the key concepts was getting the lengths of the dashes and spaces to work out. By using this piece of code, I was able to calculate how many line dashes there would be before the turtle started drawing so I could use a 'for' loop to speed the process.

  1. assign to numdash the number of dashes used to make the line
    numdash = int((distance / (self.dashLength+5)))

The picture of all of my differently drawn shapes is attached and named picture2lab10.png .

3) For the third task I had to just add in my newly created draw styles to my indoor scene form last week. The only real code of interest is the newly added setStyle() function that tells the draw function which draw style to use.

l = shape.L2( distance = 50, color='brown')
l.setStyle( 'jitter' )
l.draw(150, -75, orientation = 270)

The newly jittered, broken and dashed indoor scene is attached and labelled picture3lab10.png .

4) For the final task I needed to create a new parameterized Lsystem. For this lab, I started with the base and rule for the snowflake Lsystem but then changed the base to make it into a cross. So now my Lsystem is a cross that has miniature dips in and out all along the edge. I made a couple and put them on a triangular background. Here is the parameterized Lsystem that I used:


Unknown macro: { (5)F(90)+(5)F(90)-(7.5)F(90)+(5)F(90)+(7.5)F(90)-(5)F(90)+(5)F(90)+(5)F(90)-(7.5)F(90)+(5)F(90)+(7.5)F(90)-(5)F(90)+ }

rule F F(60)-F(120)+F(60)-F

This Lsystem, sysproj10.txt, creates that crosses in the picture that is attached and labelled picture4lab10.png .


Extension 1 - For my first extension, I fulfilled the extension that required me to make a new draw string type. For my new draw style I decided to make a stye that reminded me of sketching. This code makes it so it looks like each object has had each of its lines sketched multiple times lightly. I just used a 'for' loop on my broken line code and changed a few other things to make my shapes looked like they had been lightly sketched. The picture of my new draw style is attached and named picture5lab10.png .

Extension 2 - The second extension that I did completes the extension that asked me to make another Lsystem. I spent some time fiddling around with different bases and rules, not really using any specific starting point. I created the new Lsystem, sysproj102 and here is what it looks like:

base (50)F+(50)F-(50)F(135)(141.4)F(135)(50)F
rule F F+F-

The picture of the Lsystem that I created for this extension is attached and labelled picture6lab10.png .

What I learned

For this lab I came to understand more about how to call different types of functions, like the the difference between calling shape classes and Lsystems. Before this lab I was pretty hazy on exactly what I had to do for the different types.

Attached Pictures