#include #include #include Image *tile[5]; void main(int, char**){ Rectangle r = {0, 0, 64, 64}; ulong i; i = truerand(); print("0x%.8ux\n", i); srand(i); if(initdraw(nil, nil, "truchet wallpaper") < 0) sysfatal("initdraw: %r"); tile[0] = allocimage(display, r, CMAP8, 0, DPaleyellow); tile[1] = allocimage(display, r, CMAP8, 0, DDarkgreen); tile[2] = allocimage(display, r, CMAP8, 0, DPaleyellow); tile[3] = allocimage(display, r, CMAP8, 0, DNofill); tile[4] = allocimage(display, r, CMAP8, 1, DPurpleblue); for(i = 0; i < nelem(tile); i++) if(tile[i] == nil) sysfatal("allocimage: %r"); draw(tile[0], Rect(0, 0, 32, 32), tile[1], nil, ZP); draw(tile[0], Rect(32, 32, 64, 64), tile[1], nil, ZP); draw(tile[2], Rect(32, 0, 64, 32), tile[1], nil, ZP); draw(tile[2], Rect(0, 32, 32, 64), tile[1], nil, ZP); draw(tile[1], r, tile[0], nil, ZP); draw(tile[3], r, tile[2], nil, ZP); ellipse(tile[0], r.min, 32, 32, 16, tile[4], ZP); ellipse(tile[0], r.max, 32, 32, 16, tile[4], ZP); ellipse(tile[1], Pt(64, 0), 32, 32, 16, tile[4], ZP); ellipse(tile[1], Pt(0, 64), 32, 32, 16, tile[4], ZP); ellipse(tile[2], r.min, 32, 32, 16, tile[4], ZP); ellipse(tile[2], r.max, 32, 32, 16, tile[4], ZP); ellipse(tile[3], Pt(64, 0), 32, 32, 16, tile[4], ZP); ellipse(tile[3], Pt(0, 64), 32, 32, 16, tile[4], ZP); r.min.y = screen->r.min.y; i = 64; while(r.min.y < screen->r.max.y){ r.max.y = r.min.y + 64; r.min.x = screen->r.min.x; while(r.min.x < screen->r.max.x){ r.max.x = r.min.x + 64; draw(screen, r, tile[r.min.x + i >> 5 & 2 | lrand() & 1], nil, ZP); r.min.x = r.max.x; flushimage(display, 1); sleep(10); } r.min.y = r.max.y; i ^= 64; } flushimage(display, 1); sleep(9999990); exits(nil); }