Project 10: Non-Photorealistic Rendering
In this assignment you will implement and demonstrate two more drawing styles in the Interpreter class. To implement a new style, add another case to the if statement in the forward method of the Interpreter class.
You will enhance your scene from the last project by making use of the various drawing styles you implement. You should be able to run the scene with different styles using minimal changes to the code.
Tasks
- Implement an NPR style 'broken' that draws a line segment as two jittered
half 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 taskA.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 Interpreter.__init__ method called dashLength. You'll also need a setDash 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 taskB.py that generates a collection of shapes that show the
'dash', 'normal', 'jitter', and 'broken' 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.
- Copy your indoor scene code from last week into the working folder for this
project. Edit your scene so that it makes use of the different drawing styles.
Feel free to enhance the scene in other ways, but focus on making 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, stochastic, multirule 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 (leaves or berries). Make the shape structurally different so the change 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 requied image 4.
Extensions
- 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.
- Be more creative with tasks A and B; use programming structures and user input to go beyond the minimal required images.
Writeup
Remember, there are two components you need to hand in: your code and a writeup. Put the Python source files you wrote on the Academics server in your private directory. (You can find instructions for accessing the Academics server on the Lab FAQ.)
Make a new wiki page for your assignment in your personal wiki space. Add the following label to the page:
cs151f11proj10
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, but do not include long code segments. 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.