Task:
The purpose of this project was to use zturtle to draw objects with a new class called Crayon. This class enabled zturtle to draw any object to look as if it were drawn with a crayon. This was done fairly simply within the class by finding midpoints of the lines drawn and randomly offsetting them, lines were then drawn between these new points and have the look of a 'hand drawn' image. The width was also enlarged to give the appearance of a crayon tip. The entire resulting image consists of both lines and crayon lines that are slightly perturbed.
Using other drawing options:
The ZTurtle class could easily be modified to permit many other drawing options. One logical option may be a paint brush, which would have the appearance of a painted line. In order to achieve this, We would create a similar class to Crayon labeled Paint. Within the class, you would create multiple lines from the given points (similar to how the points are split in Crayon, but in this case, the line length would be altered slightly for each line, with multiple lines drawn in the same area to give a brush effect, and the lines would be marginally perturbed.) Within the ZTurtle class, the forward method would again have to be modified to test if self.paint (created in the __init__ method) were true. If so, a paint object would be created between the two points, else a line would be drawn. This is almost identical to the crayon function created in this project.
Benefits of inheritance in creating the Crayon class:
The Crayon class opens the possibilities of artistic rendering through different mediums. For example, a simple computer drawn tree with perfectly straight lines and matching intersections can be transformed very easily through the Crayon class into the same tree, appearing to be drawn with a crayon by hand by a child. Through this new medium, many other objects can be altered to have a new appearance. On a higher level, entire pictures can be given many different textured appearances from classes such as Crayon or Paint. It is simply another tool that enables us more control over our program and the results.
Overriding the setWidth class:
The Crayon class must override the setWidth class in ZTurtle in order to create a fatter, crayon tip line. This is so because the class is being called into the ZTurtle class, which would otherwise set the default width to the one specified. Since we cannot simply specify a greater width in the ZTurtle class because it would in turn make all lines drawn the same width, negating the variety in thickness. Thus we must define a different width for only the Crayon class that does not affect the rest of the elements when an object is being drawn.
Description of Image:
My image is on the simple side due to my over curiosity and the inevitable programming nightmare that was created when I tried to create a large, colorful country scene. I managed to salvage two of my trees and my rough outlines of houses. I also drew a simple hexagon to test what other geometric objects might appear when drawn with crayon. The final image has somewhat of a cartoon appearance due to the viarying line thickness and the sketched look. I did use loops to draw the houses in two elements: the square frame and the triangular roof. As part of drawing this image, some extensions were creating a new Lsystem for the smaller tree, and drawing completely in crayon.
Image from zturtle.py: