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 Interpreter.forward method.

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

  1. 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 a jittered start point to a jittered midpoint, the second line goes from another jittered midpoint to a jittered final point. The midpoint of the line segment is:
    (xm, ym) = ( (x0 + x1)/2, (y0 + y1)/2 )

    Once you have the midpoint, creating two jittered lines is simple. Note that for each goto statement below, 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 value.

    # 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 (x1 + jx, y1 + jy)
    # Pick the pen up
    # Go to (x1, y1)
    # Put the pen down
    
  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__ method named dashLength. Note that when you draw the dashed lines, each dash segment should be of this length, regardless of how long the line is. You will 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.
  3. Make a file taskA.py that draws a collection of shapes from last week in "normal", "jitter", "broken", and "dash" styles. Your write up should point out which examples are which.

    An image of the collection of shapes in four different styles is required image 1.

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

  5. 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, parameters, 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 3.

  6. Create a program that uses recursion in some way to draw a scene. For example, you could create a scene that draws some component of the scene, like a painting on a wall, recursively. Or, you could create a Shape class that generates its string using recursion, which is how the example below was generated. Do not forget a base case to avoid infinite recursion.

    spiral

    A scene that contains a recursively drawn element is required image 4. Describe the recursion in the write up.

Extensions

Write Up

Remember, there are two components you need to hand in: your code and a write up.

For this assignment, you will work on the Results section of the write up. The write up should include the images created as output from your programs along with brief descriptions. Be sure to include a description and image that demonstrates any extensions you undertook. You do not need to complete the other sections of the write up.

Add the following label to your Wiki page. Then follow the link to see the list of all pages that have been labeled. Ensure your page appears in this list (it may take a few minutes to appear).

cs151s12project10