Homework 2: An Electric Quilt

Due date

This homework is due on February 3, 2011. and must be submitted as a pde file to the UNCA moodle activity HW 2.

The Task

quilt1 quilt2 quilt2 quilt4 quilt5

Quilts are beautiful, but they require a great deal of skill and time to create. In this assignment, you'll find that you already have the programming skills needed to create your own electric quilt using Processing.

Read pages 51 to 68 of the textbook and then write a program that repeats a pattern of primitive shapes such as rectangles, ellipses, lines, and triangles to create an electric quilt that fills your canvas. Use a screen size of 400×400.

Keep the pattern simple! Focus on the loops.

Remember to comment your code and to submit only your source code.



Here's a fairly simple quilt that I generated along with a description of the steps that I went through in developing the program that created it.

  1. Create one "square" of the quilt. I used a circle bounded by a rectangle, both different colors.
  2. step1
  3. Introduce the variables needed to draw the square at an arbitrary position on the canvas and use those variables to draw the first square again.
  4. Write a for-loop that repeatedly draws the square across the width of the canvas. In other words, create the first row of the quilt.
  5. step3
  6. Nest the first for-loop (i.e., the loop that draws all of the columns in the first row) inside of a second for-loop that draws all of the rows.
  7. step4
  8. Make the colors a function of the position of the square.
  9. step5


Grades will be based on the following criteria.

10% creativity and aesthetics
10% image size
20% use of graphical primitives
50% use of loops
10% documentation of code