// (c) Tuomas j. Lukka #define FPARAM(name, default) float name = params->getFloat(#name, default); int tick(float ticks, float thick, int i, int size) { int x = i % (int)(size / ticks); return x < thick; } void GENERATE(TextureParam *params, int width, int height, int depth, int components, float *data) { FPARAM(type, 0); FPARAM(ticks, 5); FPARAM(thickness, 2); int i, j; float x, y; float xstep = 1.0 / width; float ystep = 1.0 / height; int ind = 0; if(type == 0 && components != 3) return; for (j = 0, y = 0; j < height; j++, y += ystep) { int ytick = tick(ticks, thickness, j, height); for (i = 0, x = 0; i < width; i++, x += xstep) { switch((int)type) { case 0: // graph paper int xtick = tick(ticks, thickness, i, width); data[ind] = (!ytick); data[ind+1] = (!xtick); data[ind+2] = ((!ytick) && (!xtick)); break; } ind += components; } } }