"Persian" Recursion

This applet uses a recursive procedure to make designs that resemble Persian rugs. You may choose 3 parameters a, b and c, and one of 6 color palettes each consisting of 16 colors numbered 0 through 15. The parameter c ( 0 thr ough 15) represents an initial color. A 257 by 257 square is drawn in the color numbered c. Label the 4 corner colors c1, c2, c3 and c4 (at the initial stage they will all be c). then a new color is determined by the formula a + (c1+c2+c3+c4)/b mod 16 and a horizontal and vertical line that divide the original square into 4 new squares are drawn in the new color. The procedure is repeated recursively until all the pixels are filled in.

Notice that since c1, c2, c3 and c4 are always between 0 and 15 and all the numbers used are integers, if b is greater than c1+c2+c3+c4, the quantity (c1+c2+c3+c4)/b will round off to zero, so the rug will just be a solid color. Experiments show that t he values of b that work the best are 2,3,4,5,6 and 7. Some combinations of a, b and c will also produce solid color rugs. (Maybe this could be given as a problem to students - what values of a, b and c will produce c in the formula?)

Surprisingly, the same values of a, b and c used with different color palettes look completely different as different assignments of colors emphasize different patterns.

To download a Windows Program that makes "Persian" rugs click here.

Scroll down until the large white square is on your screen - then enter the parameters and click on Draw rugs



Anne Burns' home page