For the project, you'll need to implement two more styles of
drawing. To implement a new style, you just need to add another case
to the if statement in the forward method of the Interpreter class.
The last step in the project is to enhance your scene from the last
project by making use of the various styles you implement this week.
You should be able to run the scene with different styles with
minimal changes to your code.
Tasks
-
Implement a style 'jitter3' that draws the line segment as three, criss-crossing jittered lines. The implementation is similar to the 'jitter' case, but
instead of drawing one line, you draw three. All three lines should begin at a point that is a short, random distance from the turtle's initial position and end at at a point that is a short, random distance from the desired end point.
This will involve several goto statements, e.g.
jx = random.gauss(0,self.jitterSigma)
jy = random.gauss(0,self.jitterSigma)
turtle.goto( x0+jx, y0+jy )
For each goto statement, the jx and jy values should be
regenerated from a Gaussian distribution (random.gauss) with a zero
mean and jitterSigma as the standard deviation. They should not all be
the same.
Make a file taskA.py that draws three copies of one of your shapes
from last week. Show the shape drawn in 'normal', 'jitter', and
'jitter3' style.
An image with three copies of a shape in different styles is required
image 1.
-
Create a 'dotted' style that draws a series of circles separated by spaces. Create a field in the TurtleInterpreter to hold the dotSize (the radius of the circle). You'll also need a
setDotSize method in the TurtleInterpreter class and a setDotSize
method and associated dotSize field in the Shape class, just as we did
with the setStyle and setJitter information.
Make a file taskB.py that generates a collection of shapes that show
the 'normal', 'jitter', 'jitter3', and 'dotted' drawing modes. Your
writeup should point out which examples are which.
An image of the collection of shapes in four different styles is
required image 2.
-
Make a copy of your indoor scene code--or create a brand new
scene--from last week and put it in a new file taskC.py. Edit your
scene so that it makes use of the different drawing styles. Feel free
to enhance it, but focus on enhancements that make use of the
different drawing styles and shape classes you've created. When you
are done, you should have something that looks a bit more like a real
painting or drawing.
The updated indoor scene is required image 3.
-
Make your own new parameterized stochastic multi-rule L-system. You can create a
variation on one of the given files or look in ABOP for inspiration.
If you create a variation, you need to do more than just add ornaments
(berries or leaves). You need to make the shape structurally
different so the difference is obvious.
Your new L-system does not have to be a tree, but it does need to
include branching, multiple rules, and at least one rule with more
than one replacement string. Describe the L-system you designed in
your writeup and explain your design choices. Make a scene or image
that includes your L-system.
A picture of the new L-system is required image 4.
Extensions
Each assignment will have a set of suggested extensions. The required tasks constitute about 85% of the assignment, and if you do only the required tasks and do them well you will earn a B+. To earn a higher grade, you need to undertake one or more extensions. The difficulty and quality of the extension or extensions will determine your final grade for the assignment. One complex extension, done well, or 2-3 simple extensions are typical.
-
Create more L-systems. Show how they differ in their design.
-
Add other drawing styles. For example, try making one that simulates a
brush by drawing many approximately parallel lines. Slight variations
in color between the different lines makes the effect better. You
might also try a pen-and-ink style with cross-hatching or just a
series of straight lines at an angle to the direction of the actual
line. Note although you are welcome to implement dashed and broken styles, they will not be counted as extensions.
-
Modify drawString so that when drawing a tree the branches droop down
like gravity is pulling at them. This involves determining the turtle's current angle. If the current heading is in the first or fourth quadrant, then gravity will make a right turn angle larger. If the current heading is in second or third quadrant, then gravity will make a right turn angle smaller.
-
Create a sequence of images to build an animation.
-
Make more shape classes that do interesting things. Making a fixed
sequence of characters is easy. Make a shape class where the strings
are the result of executing a function. L-systems are one example of
a dynamically created string, but there are many other ways to do
that.
-
Be more creative with tasks A and B. In other words, use programming
structures, user input, and code to go beyond the minimal required
image.
-
Use a Python language feature new to you (not just a new library feature or function)
Writeup and Hand-In
Before handing in your code, double check that it is well-styled:
- All variable names and function names use either camelCase or snake_case.
- All files and functions have docstrings.
- Comments are added to explain complicated code blocks.
- All variable and function names are appropriately descriptive.
- Functions are defined before any other code is added at the top level of each file.
- In a file with any functions defined, top level code is wrapped so that it won't execute if that file is imported by another.
Make a new wiki page for your assignment. Put the label cs151s14project10
on the page. Each of you needs to make your own writeup.
In addition to making the wiki page writeup, put the python files you
wrote on the Academics server in your private handin directory.
Colby Wiki
In general, your writeup should follow the outline below.
-
A brief summary of the task, in your own words. This should be no
more than a few sentences. Give the reader context and identify the
key purpose of the assignment.
-
A description of your solution to the tasks, including any images
you created. (Make sure your images are appropriately sized to fit onto the wiki page.) This should be a description of the form and
functionality of your final code. You may want to incorporate code
snippets in your description to point out relevant features. Note
any unique computational solutions you developed.
-
A description of any extensions you undertook, including images
demonstrating those extensions. If you added any modules,
functions, or other design components, note their structure and the
algorithms you used.
-
A brief description (1-3 sentences) of what you learned.
-
A list of people you worked with, including students who took the course in previous semesters, TAs, and professors. Include in this list anyone whose code you may have seen. If you didn't work with anyone, please say so.
-
Don't forget to label your writeup so that it is easy for others to find. For this lab, use cs151s14project10