CS 246 Lab 10
  1. Copy the files graphics.c, graphics.h, and Makefile from /home/mathcs/courses/cs246 to the directory where you are working.
  2. Write a program diamonds.c that draws a 10 X 10 array of diamonds in a graphics window. It must include a function void draw_diamond(graphics_context gc, double x, double y, double size) that draws one diamond centered at (x, y) with the given size. The diamonds must be drawn with random colors. The array of diamonds must be centered in the window, and there must be some space between them. See the sample output. If the window is resized, it must be redrawn so that the diamonds change size and spacing accordingly. The colors can also change. The background must be white (which you can do by drawing a rectangle).

    To compile the program, you need to edit Makefile and add an entry for diamonds. Just copy one of the other entries and change the name.

    The function double drand48() will return a random double between 0 and 1. Call it once for red, once for green, and once for blue. You should initialize the random number generator with a seed. A reasonable way to do this is srand48(getpid());. This sets the seed to the current process id. This will keep the program from using the same sequence of random numbers every time it is run. Call it in main.

  3. If you finish early, start on homework 2.