Project 10 Matthew Willett-Jeffries
Skip to end of metadata
Go to start of metadata

Matthew Willett-Jeffries

Spring 2011

Lsystems project 10

Introduction

_________________________________________________________________________________________________________________________________________________________

The purpose of this project was to introduce photorealistic drawing styles into the lsystem interpreter such that random and imprecise elements could be introduces to previously dry images. This was achieved by introducing a new field into shapes execution which took in a desired string corresponding to a given drawing style. This string was then used in the interpreter program to redefine the F command such that small changes could be made to the drawing.

Task1

_________________________________________________________________________________________________________________________________________________________
Image 1.

As seen in Image 1 above, the goal of this task was to introduce several new styles for the lineStyle fields. The first, 'jitter,' style made it so that the start and destination of the each line segment would be modified slightly in the x and y coordinates, and the second, 'broken,' style made it so that each line segment would be broken into two even parts each with modified destinations and starts.

Task 2.

_________________________________________________________________________________________________________________________________________________________
Image 2.

The goal of the second task, as can be seen above, was to introduce a new line style, dash, which drew all lines as if they were dashed lines. This was achieved such that each line would end evenly by calculating the distance of the desired line then dividing it into units of distance 5 in which the remainder was used as the final dash. As should be noted in the listed code below this task was achieved by making use of several if statements which computed first whether or not the next forward() function was the last and second whether or not the forward function should be followed by a turtle.up() or down() command.

"distance = math.sqrt((x0-xf)*2+(y0-yf)*2)

dashNum = int(distance)/5

dashRem = distance%5

turtle.width(curwidth)

turtle.goto(x0,y0)

for dash in range(dashNum):

if dash == dashNum:

if dash%2 == 0:

turtle.down()

turtle.forward(dashRem)

elif dash%2 != 0:

turtle.up()

turtle.forward(dashRem)

else:

if dash%2 == 0:

turtle.down()

turtle.forward(5)

elif dash%2 != 0:

turtle.up()

turtle.forward(5)

turtle.width(curwidth)"

Task 3.

_________________________________________________________________________________________________________________________________________________________


Image 3.

The goal of the third task was to introduce these new styles to last week's scene function such that it could be given a more drawn appearance. This was done mostly by introducing the broken and jitter linestyles to last week's scene code.

Task 4.
_________________________________________________________________________________________________________________________________________________________


Image 4.

The goal of the final task was to introduce a new complex lsystem which made use of some of the new symbols allowed. The Lsystem above is what I can up with. By using the turtle.up() and down() symbols, which were introduced last project, and the fill command, a complex spiral was created. Taking from some of the techniques for creating spirals (that I saw elsewhere and were introduced to me in earlier projects) this novel lsystem was created from scratch:

"
base AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAArule A [FXFX[FX-FX[-FX+FX]]]---
*rule X Y+Y+Y+X+X

Unknown macro: {F+F+F+F+F+F}

*
rule Y /----FFFF~X[+F]-F"

It should be noted that the base needed so many A's because the cyclical move (the sum of the angles in the A rule) was quite small. 

Extensions

_________________________________________________________________________________________________________________________________________________________

Several extensions were undertaken durring the course of this project. First several novel Lsystems were introduced and can be found in the project 10 folder. Second, a fifth lineStyle possibility was introduced which combined elements from jitter and dash. An example of this lineStyle applied to an image of my name can be seen below:

Conclusion

_________________________________________________________________________________________________________________________________________________________
Like its predecessors this project demanded ample ability manipulating and editing the preexisting lsystems and execution programs. This being said the introduction of photorealistic styles by editing the lay out of interpreter brought a novel mechanic to my understanding of lsystem such that different unique drawing styles could be used.

All files can be found in my project 10 folder. Tasks 1-4 are in files labelled Test1-4.py.
distance = math.sqrt((x0-xf)*2+(y0-yf)*2) dashNum = int(distance)/5 dashRem = distance%5 turtle.width(curwidth) turtle.goto(x0,y0) for dash in range(dashNum): if dash == dashNum: if dash%2 == 0: turtle.down() turtle.forward(dashRem) elif dash%2 != 0: turtle.up() turtle.forward(dashRem) else: if dash%2 == 0: turtle.down() turtle.forward(5) elif dash%2 != 0: turtle.up() turtle.forward(5) turtle.width(curwidth)

Labels