Project 10: Non-Photorealistic Rendering
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.
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.
To ensure the turtle is correctly positioned for a subsequent call to forward, be sure to determine the "normal" ending position before you move the turtle. After the lines have been drawn, pick up the turtle and move it to that position. (See the jitter style for an example.)
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.
As in the jtter and jitter3 styles, you need to ensure the turtle is correctly positioned for a subsequent call to forward. Determine the "normal" ending position before you move the turtle. After the dots have been drawn, pick up the turtle and move it to that position.
Make a file demo_line_styles.py that draws multiple copies of
one of your shapes from last week. Show the shape drawn in
'normal', 'jitter', and 'jitter3', and 'dotted' styles. For the
normal style, draw shapes with at least 2 different line
widths. For jitter and jitter3 styles, draw shapes with at least
2 different jitter sigmas. For the dotted style, draw shapes
with at least 2 different dot sizes.
An image demonstrated your different styles is required image 1.
Make a copy of your home scene code--or create a brand new
scene--from last week and put it in a new file home.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 home scene is required image 2.
Make your own new parameterized stochastic multi-rule L-system and save it in a file named myLsystem.txt. 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. In a file named demo_myLsystem.py, Make a scene or image that includes your L-system.
A picture of the new L-system is required image 3.
These are just examples, not necessarily recommendations. Please feel welcome and encouraged to design your own. A great extension genuinely interests you, pushes your understanding of CS, and inspires you to learn something new.
- 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 your main code. In other words, use programming structures, user input, and code to go beyond the minimal required image.
Hand-in and Report
- Put the python files you wrote on the Courses server in your private directory in a folder named Project10.
- Make a new wiki page for your assignment. Put the label cs151f18project10 on the page.
In general, your report should follow the outline below.
- Title includes your name and clearly describes the project.
- Section headings are used to delineate distinct sections of the report.
- Abstract identifies key lecture concepts (e.g. code structres, data types, and libraries) relevant to the project.
- Abstract explains why key lecture concepts are important to achieving project goals.
- Abstract identifies program output(s), giving context to the project tasks.
- Solutions to tasks are described, focusing on how you used key lecture concepts to solve each task.
- Required images/outputs are present and clearly labeled.
- Reflection at the end of the report addresses how the lecture concepts mentioned in the abstract made this project possible. If you can think of a more elegant way to achieve the same results, please share!
- Sources, imported libraries, and collaborators are cited, or a note is included indicating that none were referenced.
- Don't forget to label your writeup so that it is easy for others to find. For this project, use cs151f18project10
This week, graders will focus on how you integrate text and images. To check whether you've made your images and their text clear, you may ask yourself the following questions:
- Does the text describe the content of the image?
- Does the text describe how the content was generated?