lab11

Lab 11 Write-up

Task:

The task for this project was to create a class which would create drawings which imitate a crayon. To do this we perturbed the starting point, ending point, and mid point for each line. I also varied the width of the lines.

For a Paintbursh:

A paintbrush, like a crayon does not draw lines the same way that the turtle does. Both a brush and a crayon are neither as consistent nor as precise as the turtle. In order to imitate a brush one would have to create a number of lines in order to simulate each bristle. Also, since the paint brush will not draw a perfect line from point to point, it would be important to create a perpendicular off-set for both point 1 and point 2. Then, since the paint is not uniformly distributed, one would have to randomly distribute the paint, perhaps using a Gaussian distribution. Also, since the lines from a brush are not as consistent as the width of the lines from the turtle, one would have to vary the width of the brush strokes

Benefits of inheriting classes

The inheritance of a class is very helpful because it prevents duplication of code. Duplicating code reduces the amount of time that the programmer needs to spend coding, and it also reduces the number of places where there could be bugs in the code, which is helpful when debugging the program.

Why override the setWidth function?

I had to override the setWidth function because when imitating a crayon it is important to vary the width of each line. If I had not overridden the setWidth function, all of the lines would have uniform width and it would not look like the picture was drawn in crayon.

Final Image

To create my final image, I started by setting 4 different L-Systems, 3 of which have multiple rules for the same symbol. I then created the window and called the crayon class. Then I drew the L-systems, and imported buildings from my cityscape2 project.

For an extention, I created a crayon circle for the sun. To do this I created a series of short lines and turned right 18 degrees for each line. This gives the appearance of a circle while still being able to draw use the crayon class.