# CPSC 120: Lab Assignment 3

### Due at 12:19 pm on Friday, 02/19/2014

Home | Calendar | Announcements | Assignments | Example Code | Notes

## Problem Set

Your solutions to the following problems should be placed in a folder named "lab3". When you have finished the assignment, copy this folder and its contents to your turn-in directory.

### Problem One

The Dutch painter Piet Mondrian (1872-1944) was known primarily for his geometric style of painting (which he termed "neoplasticism"). In his paintings, Mondrian reduced his subjects to essentials of form and color, creating compositions of adjoining rectangles, often using only the "artist primaries" of red, yellow, and blue for the painting's color scheme. Other color schemes occur in some of his works, as well, but the geometric character of his works was consistent throughout most of his career.

Some of his works can be seen at these sites:

Your job here is to write a program that produces an image in the neoplasticist style. You should satisfy these constraints:

1. There should be at least 10 rectangular forms in the image.
2. Every visible shape in the drawing must be a rectangle. In other words, your drawing must completely fill the window, and no rectangles should overlap. Further, if one rectangle nests inside another one, both rectangles should have the same width or the same height.
3. The rectangles should all have a strong outline, either black or dark gray.
4. Some rectangles should be nested in other rectangles, but not all of them.
5. Your color scheme must consist of exactly four colors, though the distribution of those colors is up to you.

The choice of colors is yours (though pastels would make the De Stijl adherents sad), as is the number and arrangement of rectangular forms.

Save your sketch in the lab3 folder with the name "prob1".

### Problem Two

Write a program that produces a sketch consisting of five or more colorful circles on a white background, along the following lines:

• Your drawing should have at least five circles. It can have more, if you want (no limit), but the animation requirement will start to get severe.
• Each of the circles should move around the window, bouncing off of the edges. Study the "bouncing ball" example from class to gain insight into this.
• Each of the circles should have a different fill and different outline color.
• Each circle should have something less than full transparency, in both its fill color and outline (though the level of transparency of fill and outline can be different for a circle).
• Each circle should be a different size
• As the circles pass each other, they should just overlap: don't worry about simulating these collisions

Save your sketch in the lab3 folder with the name "prob2".

### Turn In

Make a folder in your turn in directory named "lab3". Copy both of your solutions in to this folder. Consult the Linux tutorial from Lab #0 if you need a reminder of the details.

### Standards

• Your code must be syntactically correct. Any solution that contains a syntax error anywhere (and hence crashes when you hit the "play" button") will receive no credit.

If you run into any trouble here, please ask me or one of the TAs for help.

• Naturally, your code must be behaviorally correct, though partial credit is always given for partial solutions.

John H. E. Lasseter