Lab Assignment 10

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0


If I left it as jx and jy for the second pair, it doesn't "break" because it is drawing from the same place.
That was an easy fix, however, and with little pain, I ended up with this picture:

The second task was to create a dashed line style.
Like in the other styles, I assigned the beginning and end points to (x0, y0) and (xf, yf).
Then, inside a for loop in range int( distance/( self.dashLength*2 ) ), I just had the turtle go forward, then pick it-
self up and go forward again. Once it was done, I had it pick up, go to the end point, and put down.
My test code was accidentally written over, but I recreated it with incorrect colors and positioning, but the code is basically the same.

Here was the picture of all four:

The third task was to alter our scene code from the previoius lab. All I did was add one line for each shape I wanted to change: [shape].setStyle( [either 'jitter' or 'broken'] ).
Here is the picture:


base (5)F
rule (x)F (x/2)F[(x)F+(x)F](x)F--(x)F+(x/2)F

Using several different instances of this l-system together, I created a snowflake image.

Then I kind of went overboard in drawing lots of versions of it because I found the resulting picture really surprisingly cool. Here it is, in normal, jitter, and dashed form:

The different pattern on the inside is using an angle of 50 rather than 20.


...and so on for every combination of greater than or less than possibility. However, I wrote the code, and tested the style on a few of my shapes. I must say, I am a little proud of how it turned out.

It's a little hard to tell, but there are slight color differences.


Though some common little problems came up (including me having to add width to Shape and all of my Shape-derived classes and in a bunch of other places) and it took me a while to realize what I had to do for the dash effect, I didn't really encounter any major problems with this lab and felt pretty comfortable with the l-system, shape, and interpreter code. I definitely felt like I knew what I was doing. Though now (thanks to my width problems) I hope I have a better understanding of-or at least am more comfortable with-the relationship between the three main classes. I actually really enjoyed this lab.