
Often it is possible to create a number of shapes in a specific pattern algorithmically
(i.e., using a loop and calculating the position, size, velocity, etc.). When
combined with movement, this has the possibility of producing a very interesting
effect, with very little effort. In fact, this is the basis of most screen
savers, which, arguably, can be considered an
art form. While he did not use a computer, MC Escher used this principle to create incredible works of art.
In this project, you will create an environment that helps artists use mathematical expressions to generate pictures. Instead of simply building and evaluating expressions of numeric values like a standard calculator, you will allow the user to create expressions that evaluate to colors and then eventually to images. This may sound a little strange, but the results can be quite spectacular. Here is the general idea: an image is really a expression that maps points (x,y) to colors (r,g,b). This program simply evaluates that expression for each pixel (x-, y-point) in the image and stores resulting color.
For a work of art to be considered algorithmic art, its creation must include a process based on an algorithm devised by the artist. Here, an algorithm is simply a detailed recipe for the design and possibly execution of an artwork, which may include computer code, functions, expressions, or other input which ultimately determines the form the art will take. Unfortunately, it is not always easy to determine how the algorithm controls changing specific aspects of the image. This is where the software can help make it easy for the artist to develop an intuition how to generate and manipulate the resulting images by developing ways to parameterize these artistic algorithms.
Specification
Write an arithmetic interpreter that allows users to enter, change, combine, and evaluate arithmetic expressions interactively. A user of your program should be able to enter expressions interactively while your program keeps track of and evaluates them. Your program should save each expression entered as an Expression Tree so that it can be evaluated, combined, transformed, or printed whenever needed without requiring re-parsing the user's input.
Each time the user enters a complete expression by pressing return, it should be evaluated and the resulting image displayed for the user, then the user should be prompted to enter another. This is the so-called read-eval-print loop used in Scheme, Lisp, Smalltalk and other interpreted programming languages. The interpreter should ignore lines of input that are empty, i.e., contain only zero or more spaces and lines that begin with the comment character "#".
For this program, a color represents three real numbers, one each for the red, green and blue component, where the component values range from -1 to 1. For example, [-1,-1,-1] is black, [1,-1,-1] is red, and [1,1,-1] is yellow. During computation of an expression, the value of each component should not be restricted to this range, but the final result of the expression should be clamped to within the range -1 to 1. By default, like the colors, the domain of the image over X and Y is from -1 to 1. The upper left corner of the image will be (-1,-1) and the lower right corner will be (1, 1).
For example, here are several images generated from basic expressions.
Design Goals
This assignment provides a context to begin thinking about issues of design and coding style.- Making your code flexible. You will build this project in several steps, but you will not know the exact details of the next steps beforehand. Thus, you should try to structure your code so that later parts can be easily added on (i.e., you will find out for yourself if the code you designed really was flexible).
- Developing a clean coding style. Your code should adhere to modern coding standards, like those found in most serious coding shops throughout the country. This encompasses everything from formatting your code consistently to structuring your code in small, single-purpose, functions.
Unlike previous courses, where the main focus of projects was to write algorithms, in this project the algorithms will be relatively straightforward (and you will be given code to start).
Stages
This project will be released in stages. Part of the reason for this is to encourage you to think about code flexibility. For example, you can see that in each stage, you will be adding a different kinds of functions. If you structure you code in the first part to make it easy to add new kinds of functions, you will have an easier time on the later parts.- Part 1: get to know the given code, then refactor it to make adding new functions and language features easy
- Part 2: add interesting mathmatical functions and variables
- Part 3 (optional): add a wider variety of functions and animation
TA Sign Off
As will be true off all the assignments in this class, the primary goal is about design and style. Getting working code is a start, but it is not enough to receive credit. For this project, your TAs will be acting as industry-style code reviewers. Just like in industry, your code will not count until your code reviewer signs-off on it.
Here's how things will work: you will write your code, implementing the appropriate functionality and doing your best to abide by the design guidelines. Then, you submit your code and email your assigned TA. He or she will reply (within approximately 24 hours) with some suggestions for improvement. You'll make changes and resubmit. You might go back and forth a few times. Eventually, your TA will be happy with your version and you can consider yourself Signed Off.
What if my Code is not Signed Off before the deadline?
Until your code is signed off, you cannot move on to the next part. So if your code is not signed of for part one by the deadline --- you will not be able to start Part 2 even though we will release the details. There is no direct grading penalty for getting signed off on Part 1, but the final deadline is the same for everyone, so getting behind can put you in a bad position. The best advice is to finish the implementation of each of the parts early, like within the first 2 or 3 days, then you will have plenty of time to get feedback from your TA and still get sign-off.
Grading
Grading for this assignment is simple, simply get all parts submitted and signed off on. As long as you start each of the parts early and are responsive to TA feedback, you should have no trouble getting full credit.What you have submitted | Grade |
---|---|
Parts 1, 2, and 3 have been signed off on. | A |
Parts 1 and 2 have been signed off on. Part 3 has been submitted and works, but there are still some style problems so your TA has not signed off. | A- |
Parts 1 and 2 have been signed off on | B+ |
Only Part 1 has been signed off on | C |
Resources
- Artificial Evolution for Computer Graphics by Karl Sims (the original paper and inspiration for this project)
- Manipulating Parameters for Algorithmic Image Generation by Mike King