/* Generate a large nonrepeating image by summing small repeating elements. * * Because the sizes of the small repeating elements are three * successive Fibonacci numbers, they are relatively prime, and their * ratios don’t closely approximate simpler ratios. Nevertheless, the * picture has quite a bit of visible regularity, because e.g. every * 104 pixels the 8 and 13 cycles coincide, and every 168 pixels the 8 * and 21 cycles coincide. */ #include "ppmp6.h" enum { ww = 256, hh = 256 }; ppm_p6_color image[ww][hh]; void tile_points(ppm_p6_color color, int dx, int dy) { for (int y = 0; y < hh; y += dy) { for (int x = 0; x < ww; x += dx) { image[y][x].r += color.r; image[y][x].g += color.g; image[y][x].b += color.b; } } } int main(int argc, char **argv) { ppm_p6_color red = { 128, 0, 0 }; tile_points(red, 8, 21); ppm_p6_color green = { 0, 128, 0 }; tile_points(green, 13, 13); ppm_p6_color cerulean = { 64, 64, 255 }; tile_points(cerulean, 21, 8); ppm_p6_output_image(image[0], ww, hh); return 0; }