CS 151: Project #10

Project 10: Non-Photorealistic Rendering

Main course page

For the assignment, 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.


  1. 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 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.

  2. 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 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.

  3. Make a copy of your indoor scene code 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'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.

  4. Make a 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 requied image 4.



Make a new wiki page for your assignment. Give the page a useful title using English words. Put the label cs151s10proj11 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.

Colby Wiki

In general, your writeup should follow the outline below.