Project 10: Non-Photorealistic Rendering
For the assignment, you'll need to implement two more styles of drawing in the Interpreter class. 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 using minimal changes to the code.
Implement a style 'broken' that draws the line segment as two jittered
line segments. The implementation is similar to the 'jitter' case, but
instead of drawing one line, you draw two. One line goes from the
jittered start point to a jittered midpoint, the second line goes from
another jittered midpoint to the jittered final point. The midpoint of
the line segment is:
(xm, ym) = ( (x0 + xf)/2, (y0 + yf)/2 )
Once you have the midpoint, creating two jittered lines is simple.
# Pick the pen up # Go to (x0 + jx, y0 + jy) # Put the pen down # Go to (xm + jx, ym + jy) # Pick the pen up # Go to (xm + jx, ym + jy) # Put the pen down # Go to (xf + jx, yf + jy) # Pick the pen up # Go to (xf, yf) # Put the pen down
Note that 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 test10a.py that draws three copies of one of your shapes from last week. Show the shape drawn in 'normal', 'jitter', and 'broken' style.An image with three copies of a shape in different styles is required image 1.
Create a 'dash' style that draws straight, but does not draw a solid
line. Do not hard code the dash length. Instead, create a field in the
Interpreter init to hold the dashLength. You'll also need a
dash method in the Interpreter class and a setDash
method and associated dash field in the Shape class, just as we did
with the style and jitter information.
Make a file test10b.py that generates a collection of shapes that show the 'dash', 'normal', 'jitter', and 'broken' drawing modes. Your writeup should be able to point out which 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 from last week and put it in a
new file. 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're 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 a parameterized L-system. You can create a variation on sysTree
or sysTree2 or look in ABOP for inspiration. It does not have to be a
tree. Describe the L-system you designed in your writeup and explain
your design choices. Make a scene or image that includes your
A picture of the new L-system is requied image 4.
- 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.
- Modify drawString so that when drawing a tree the branches droop down like gravity is pulling at them.
- 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.
Make a new wiki page for your assignment. Give the page a useful title using English words. Put the label cs151s10proj10 in the label field at the bottom of 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 handin directory.
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. 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.
- Don't forget to label your writeup so that it appears in the listing on the main wiki page for the course. For this lab, use cs151s10proj10