1 /* erase.c: Erase the screen in various more or less interesting ways.
2 * (c) 1997 by Johannes Keukelaar <johannes@nada.kth.se>
3 * Permission to use in any way granted. Provided "as is" without expressed
4 * or implied warranty. NO WARRANTY, NO EXPRESSION OF SUITABILITY FOR ANY
5 * PURPOSE. (I.e.: Use in any way, but at your own risk!)
15 erase_window(Display *dpy, Window window, GC gc,
16 int width, int height, int mode, int delay)
19 int i, j, line, num_lines=0, granularity, max_num;
25 clear_lines = (int *)calloc(max_num, sizeof(int));
28 if(mode<0 || mode>=NUM_MODES)
29 mode = random()%NUM_MODES;
34 for(i = 0; i < height; i++)
36 for(i = 0; i < height; i++)
41 clear_lines[i] = clear_lines[r];
47 for(i = 0; i < width; i++)
48 clear_lines[i] = i+height;
49 for(i = 0; i < width; i++)
54 clear_lines[i] = clear_lines[r];
60 for(i = 0; i < width/2; i++)
61 clear_lines[i] = i*2+height;
62 for(i = 0; i < height/2; i++)
63 clear_lines[i+width/2] = i*2;
64 for(i = 0; i < width/2; i++)
65 clear_lines[i+width/2+height/2] = width-i*2-(width%2?0:1)+height;
66 num_lines = width+height/2;
70 for(i = 0; i < max_num/4; i++)
72 clear_lines[i*4] = i*2;
73 clear_lines[i*4+1] = height-i*2-(height%2?0:1);
74 clear_lines[i*4+2] = height+i*2;
75 clear_lines[i*4+3] = height+width-i*2-(width%2?0:1);
82 for(i = 0; i < width*2; i++)
84 line = (i/16)*16-(i%16)*15;
85 if(line>=0 && line<width)
87 clear_lines[j] = height+line;
96 for(i = width*2; i >= 0; i--)
98 line = (i/16)*16-(i%16)*15;
99 if(line>=0 && line<width)
101 clear_lines[j] = height+line;
109 for (i = 0; i < num_lines; i++)
111 if(clear_lines[i] < height)
112 XDrawLine (dpy, window, gc, 0, clear_lines[i], width,
115 XDrawLine (dpy, window, gc, clear_lines[i]-height, 0,
116 clear_lines[i]-height, height);
118 if ((i % granularity) == 0)
120 usleep (delay*granularity);
127 XClearWindow (dpy, window);