/* Generate a weave texture with 6 operations per pixel. */ #include #include "ppmp6.h" enum { ww = 512, hh = 512 }; ppm_p6_color image[hh][ww]; int main(int argc, char **argv) { ppm_p6_color palette[] = { { .r = .3, .g = .3, .b = .3 }, { .r = .8, .g = .8, .b = 1 }, { .r = 1, .g = 1, .b = .8 }, }; int mask = 4; if (argc > 1) mask = atoi(argv[1]) << 2; /* 1 is default; try 2, 3, 4, 5 */ for (int y = 0; y < hh; y++) { for (int x = 0; x < ww; x++) { image[y][x] = palette[(x^y) & mask ? (x ^ x>>1) & 1 : (y ^ y<<1) & 2]; } } ppm_p6_output_image(image[0], ww, hh); return 0; }