1 /*
2 * Other modes
3 *
4 * mixer, cells modes and improved Spiral by Daniel Cabeza Gras
5 * ( bardo@clip.dia.fi.upm.es )
6 *
7 */
8
9 #include <X11/X.h>
10 #include <X11/Xlib.h>
11 #include <X11/Xutil.h>
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <math.h>
15 #include "trippy.h"
16 #include "lmath.h"
17 #include "waves.h"
18
19 extern XEvent event;
20
21 void
exit_spiral()22 exit_spiral()
23 {
24 return;
25 }
26
27 void
draw_spiral(int winno)28 draw_spiral(int winno)
29 {
30 /* A spiral has the formula rad=ang */
31
32 XPoint plotme;
33 float ang=0.0;
34 short clr=rndm(numcolors-1);
35 int theend= math_dist(0,0,CX[winno],CY[winno]);
36 float fact =(float)options.number/3;
37 int useCX= CX[winno]>>1;
38 int useCY= CY[winno]>>1;
39
40 do
41 {
42 plotme=PolartoRect(ang*fact,ang);
43
44 /* fprintf(stderr,"ang= %f plotme = (%d,%d)\n",ang,plotme.x, plotme.y); */
45
46 ang+=(float)M_PI/737;
47 if((abs(plotme.x)<(useCX))&&(abs(plotme.y)<(useCY)))
48 XDrawPoint(display,window[winno],color_gcs[clr],
49 plotme.x+useCX,plotme.y+useCY);
50
51 clr--;
52 if(clr<=0)
53 clr=numcolors-1;
54 } while((((ang*fact)*.66667)) <= theend);
55 }
56
57 void
exit_wandering()58 exit_wandering()
59 {
60 return;
61 }
62
63 void
wander(int winno,int * x,int * y)64 wander(int winno,int *x, int *y)
65 {
66 int spoo;
67
68 XDrawPoint(display,window[winno],color_gcs[HC[winno]],*x,*y);
69 if((spoo=rndm(3))==1)
70 *x+=(rndm(3));
71 else if (spoo==2)
72 *x-=(rndm(3));
73 if((spoo=rndm(3))==1)
74 *y+=(rndm(3));
75 else if (spoo==2)
76 *y-=(rndm(3));
77 if (*x<=0)
78 *x=CX[winno];
79 else if (*x>=CX[winno])
80 *x=0;
81 if (*y<=0)
82 *y=CY[winno];
83 else if (*y>=CY[winno])
84 *y=0;
85
86 return;
87 }
88
89 void
exit_funky()90 exit_funky()
91 {
92 return;
93 }
94
95 void
draw_funky(int winno)96 draw_funky(int winno)
97 {
98 static float lengthmod= 0.1;
99 static float length=1;
100 static float ang=0.0;
101 static short clr=0;
102 XPoint plotme,plotme2;
103 int halfX=CX[winno]>>1;
104 int halfY=CY[winno]>>1;
105
106 int howfunky=options.number; /* just HOW funky do you want it? */
107
108 length += lengthmod;
109 if (length <= 0.0 || length >= M[winno]) {
110 lengthmod *= -1;
111 }
112 plotme=PolartoRect(length,ang);
113
114 if(howfunky==1)
115 {
116 XPoint eris[5]; /* -><- Hail Eris! -><- */
117 plotme2=PolartoRect(length,ang+M_PI_2);
118 eris[0].x=eris[4].x=plotme.x+(halfX);
119 eris[0].y=eris[4].y=plotme.y+(halfY);
120 eris[1].x=plotme2.x+(halfX);
121 eris[1].y=plotme2.y+(halfY);
122 eris[2].x=(halfX)-plotme.x;
123 eris[2].y=(halfY)-plotme.y;
124 eris[3].x=(halfX)-plotme2.x;
125 eris[3].y=(halfY)-plotme2.y;
126 XDrawLines(display,window[winno],color_gcs[clr],eris,5,
127 CoordModeOrigin);
128 }
129 else if(howfunky==2)
130 {
131 XPoint plotme3;
132 XPoint eris[4];
133 plotme2 = PolartoRect(length,ang+(.66667*M_PI));
134 plotme3 = PolartoRect(length,ang+(1.3333*M_PI));
135 eris[0].x=eris[3].x=plotme.x+(CX[winno]>>1);
136 eris[0].y=eris[3].y=plotme.y+(CY[winno]>>1);
137 eris[1].x=plotme2.x+(CX[winno]>>1);
138 eris[1].y=plotme2.y+(CY[winno]>>1);
139 eris[2].x=plotme3.x+(CX[winno]>>1);
140 eris[2].y=plotme3.y+(CY[winno]>>1);
141 XDrawLines(display,window[winno],color_gcs[clr],eris,4,
142 CoordModeOrigin);
143 }
144 else
145 {
146 XDrawLine(display,window[winno],color_gcs[clr],
147 plotme.x+(CX[winno]/2),plotme.y+(CY[winno]/2),
148 (CX[winno]/2)-plotme.x,(CY[winno]/2)-plotme.y);
149 }
150 ang+=(float)(M_PI/737);
151 clr--;
152 if(clr<=0)
153 clr=numcolors-1;
154 return;
155 }
156
157 /*
158 * Ripple in still water
159 * Where there is no pebble tossed
160 * Nor wind to blow
161 * - R. Hunter
162 */
163
164 void
draw_ripple(int winno)165 draw_ripple(int winno)
166 {
167 int clr;
168 int a;
169 XGCValues gcval;
170
171 if(options.opt1%2)
172 {
173 int x,y;
174 register long dist;
175 int *centerx=calloc(options.number,sizeof(int));
176 int *centery=calloc(options.number,sizeof(int));
177 int *colors=calloc(options.number,sizeof(int));
178 for(a=0;a<options.number;a++)
179 {
180 centerx[a]=rndm(CX[winno]);
181 centery[a]=rndm(CY[winno]);
182 colors[a]= rndm(numcolors);
183 }
184 for(x=0;x<CX[winno];x++)
185 for(y=0;y<CY[winno];y++)
186 {
187 int mindist=999999;
188 for(a=0;a<options.number;a++)
189 {
190 if (((dist=math_dist(centerx[a],centery[a],x,y)))<mindist)
191 {
192 mindist=dist;
193 }
194 }
195 /* clr /= options.number; */
196 clr = mindist%(numcolors-1);
197 XDrawPoint(display,window[winno],color_gcs[clr],x,y);
198 }
199
200 }
201 else
202 {
203 wave_radial(winno,0,rndm(CX[winno]),rndm(CY[winno]),M[winno],0,25,50);
204 for(clr=1;clr<numcolors;clr++)
205 {
206 gcval.function=GXxor;
207 XChangeGC(display,color_gcs[clr],GCFunction,&gcval);
208 }
209
210 for(a=0;a<(options.number*2);a++)
211 {
212 wave_radial(winno,0,rndm(CX[winno]),rndm(CY[winno]),M[winno],0,25,50);
213 }
214 }
215 return;
216 }
217
218 void
exit_ripple()219 exit_ripple()
220 {
221 int clr;
222 XGCValues gcval;
223
224 for(clr=1;clr<numcolors;clr++)
225 {
226 gcval.function=GXcopy;
227 XChangeGC(display,color_gcs[clr],GCFunction,&gcval);
228 }
229 }
230
231 void
exit_xstatic()232 exit_xstatic()
233 {
234 return;
235 }
236
237 void
draw_static(int winno)238 draw_static(int winno)
239 {
240 int x,y;
241
242 randomize_colors();
243 for(y=0;y<=CY[winno]>>1;y++)
244 for(x=0;x<=CX[winno];x++)
245 {
246 int r=rndm(numcolors-1)+1;
247 XDrawPoint(display,window[winno],color_gcs[r],x,y);
248 XDrawPoint(display,window[winno],color_gcs[r],CX[winno]-x,CY[winno]-y);
249 }
250 }
251
252
253 void
exit_mixer()254 exit_mixer()
255 {
256 return;
257 }
258
259 /* The paint mixer, by //)aniel Cabeza Gras (bardo@clip.dia.fi.upm.es) */
260 void
draw_mixer(int winno)261 draw_mixer(int winno)
262 {
263 int x,y,X,Y,Color,HYP,fact;
264 int useCX = rndm(CX[winno]);
265 int useCY = rndm(CY[winno]);
266
267 HYP = (useCX*useCX+useCY*useCY)/4;
268 fact = options.number * 4;
269
270 for(y=0;y<CY[winno];y++)
271 {
272 Y=y-(useCY);
273 if (XCheckMaskEvent(display,~0L,&event)==True)/* check the outside world */
274 handle_event(&event);
275 for(x=0;x<CX[winno];x++)
276 {
277 X=x-useCX;
278 Color=((X==0)&&(Y==0)) ? 0 :
279 (((int)floor((((atan2((double)Y,(double)X)/M_PI)+1)/2+
280 (1+cos(M_PI*(double)(X*X+Y*Y)/HYP*fact))/(fact>>1))*
281 (numcolors-1)))%(numcolors-1))+1;
282 XDrawPoint(display,window[winno],color_gcs[Color],x,y);
283 }
284 }
285 }
286
287 void
exit_taffy()288 exit_taffy()
289 {
290 return;
291 }
292
293 /* taffy maker, by Steve Richardson (prefect@sidehack.gweep.net)
294 * based off of paint mixer
295 */
296 void
draw_taffymaker(int winno)297 draw_taffymaker(int winno)
298 {
299 int x,y,X,Y,Color,HYP,fact;
300 fact = options.number * 2;
301
302 HYP = (CX[winno]*CX[winno]+CY[winno]*CY[winno])/4;
303 for(y=0;y<CY[winno];y++)
304 {
305 Y=y-(CY[winno]/2);
306 if (XCheckMaskEvent(display,~0L,&event)==True)
307 handle_event(&event);
308 for(x=0;x<CX[winno];x++)
309 {
310 X=x-(CX[winno]/2);
311 Color=((X==0)&&(Y==0)) ? 0 :
312 (((int)floor((((atan2((double)X,(double)Y)/M_PI)+1)/2+
313 (1+sin(M_PI*(double)(X*X-Y*Y)/HYP*fact))/fact)*
314 (numcolors-1)))%(numcolors-1))+1;
315
316 XDrawPoint(display,window[winno],color_gcs[Color],x,y);
317 }
318 }
319 }
320
321 void
exit_cells()322 exit_cells()
323 {
324 return;
325 }
326
327 /* The cells by //)aniel Cabeza Gras (bardo@clip.dia.fi.upm.es) */
328 void
draw_cells(int winno)329 draw_cells(int winno)
330 {
331 int x,y,Color;
332 double fact = (double) options.number / (double) CY[winno];
333
334 for(y=0;y<CY[winno];y++)
335 {
336 if (XCheckMaskEvent(display,~0L,&event)==True)
337 handle_event(&event);
338 for(x=0;x<CX[winno];x++)
339 {
340 Color=(((int)floor((sin(M_PI*(double) x*fact)*
341 sin(M_PI*(double) y*fact) + 1)/2*
342 (numcolors-1))) %(numcolors-1))+1;
343
344 XDrawPoint(display,window[winno],color_gcs[Color],x,y);
345 }
346 }
347 }
348
349 void
exit_dcurve()350 exit_dcurve()
351 {
352 return;
353 }
354
355 void
draw_dcurve(int winno)356 draw_dcurve(int winno)
357 {
358 int i,x,y;
359
360 XPoint** bezi;
361
362 bezi = (XPoint**)malloc(options.number*sizeof(XPoint*));
363
364 for(i=0;i<options.number;i++)
365 {
366 XPoint makeme[4];
367 int j;
368
369 for(j=0;j<4;j++)
370 {
371 makeme[j].x = rndm(CX[winno]);
372 makeme[j].y = rndm(CY[winno]);
373 }
374
375 bezi[i] = (XPoint*)malloc(sizeof(XPoint)*21);
376 memcpy(bezi[i], Bezier(makeme,21), sizeof(XPoint)*21);
377 }
378
379 for(x=0;x<CX[winno];x++)
380 for(y=0;y<CY[winno];y++)
381 {
382 unsigned int d = 999999;
383 for(i=0;i<options.number;i++)
384 {
385 unsigned int dp;
386 if((dp=curve_dist(x,y,bezi[i],21))<d)
387 d=dp;
388 }
389 if(d==0) d=1;
390 XDrawPoint(display,window[winno],color_gcs[d%numcolors],x,y);
391 }
392
393 for(i=0;i<options.number;i++)
394 {
395 free(bezi[i]);
396 }
397 free(bezi);
398 }
399
400 void
exit_dline()401 exit_dline()
402 {
403 return;
404 }
405
406 void
draw_dline(int winno)407 draw_dline(int winno)
408 {
409 int *x1,*x2,*y1,*y2;
410 int i,x,y;
411
412 x1=malloc(options.number * sizeof(int));
413 y1=malloc(options.number * sizeof(int));
414 x2=malloc(options.number * sizeof(int));
415 y2=malloc(options.number * sizeof(int));
416 /* first, we draw the line */
417 for(i=0;i<options.number;i++)
418 {
419 x1[i]=rndm(CX[winno]); x2[i]=rndm(CX[winno]);
420 y1[i]=rndm(CY[winno]); y2[i]=rndm(CY[winno]);
421 XDrawLine(display,window[winno],color_gcs[rndm(numcolors)],
422 x1[i],y1[i],x2[i],y2[i]);
423 }
424 for(x=0;x<CX[winno];x++)
425 for(y=0;y<CY[winno];y++)
426 {
427 unsigned int d=999999;
428 for (i=0;i<options.number;i++)
429 {
430 unsigned int dp;
431 if((dp=line_dist(x,y,x1[i],y1[i],x2[i],y2[i]))<d)
432 d=dp;
433 }
434 if(d==0) d=1;
435 XDrawPoint(display,window[winno],color_gcs[d%numcolors],x,y);
436 }
437 }
438
439 void
exit_sunrise()440 exit_sunrise()
441 {
442 return;
443 }
444
445 void
draw_sunrise(int winno)446 draw_sunrise(int winno)
447 {
448 int x,y,dx,dy,color,dist,angle;
449 int xcenter= CX[winno]>>1;
450 int ycenter= CY[winno]>>1;
451
452 angle=0; dist=0;
453
454 for(y=0;y<CY[winno];y++)
455 {
456 if (XCheckMaskEvent(display,~0L,&event)==True)
457 handle_event(&event);
458 for(x=0;x<CX[winno];x++)
459 {
460 color = (angle % 64) ^ dist;
461 dx = x - xcenter;
462 dy = y - ycenter;
463 dist = math_dist(0,0,dx, dy);
464 angle = (int)(RecttoPolar(dx, dy)*options.number);
465 do
466 {
467 /* color = color%(numcolors-1); */
468 if(color<=0)
469 color+=(numcolors-1);
470 else if (color>=numcolors)
471 color-=numcolors;
472 } while (color<=0 || color>=numcolors);
473
474 XDrawPoint(display,window[winno],color_gcs[color],x,y);
475 }
476 }
477 return;
478 }
479
480
481 void
exit_tunnel()482 exit_tunnel()
483 {
484 return;
485 }
486
487 void
draw_tunnel(int winno)488 draw_tunnel(int winno)
489 {
490 int i,rev;
491 XPoint points[4];
492 int npoints = 4, shape = Convex, mode = CoordModeOrigin;
493 float frac;
494 int min_x, max_x, mid_x, min_y, max_y, mid_y;
495 int useCX = CX[winno] / (options.mirrors+1);
496 int useCY = CX[winno] / (options.mirrors+1);
497
498 rev=rndm(2);
499
500 min_x = 0 - useCX/2;
501 max_x = useCX * 3 / 2;
502 mid_x = useCX / 2;
503 min_y = 0 - useCY/2;
504 max_y = useCY * 3 / 2;
505 mid_y = useCY / 2;
506 points[0].y = points[2].y = (short) mid_y;
507 points[1].x = points[3].x = (short) mid_x;
508 for (i=0; i<numcolors; i++)
509 {
510 frac = (float) i/numcolors;
511 points[0].x = (short) (min_x + useCX * frac);
512 points[2].x = max_x - points[0].x + min_x;
513 points[1].y = (short) (min_y + useCY * frac);
514 points[3].y = max_y - points[1].y + min_y;
515 if(rev)
516 XFillPolygon (display, window[winno], color_gcs[numcolors-i-1], points,
517 npoints, shape, mode);
518 else
519 XFillPolygon (display, window[winno], color_gcs[i], points,
520 npoints, shape, mode);
521 }
522 if(options.mirrors)
523 {
524 int x,y;
525 for (x=0;x<=options.mirrors;x++)
526 for (y=0;y<=options.mirrors;y++)
527 {
528 XCopyArea(display,window[winno],window[winno],color_gcs[1],
529 0,0,useCX,useCY,useCX*x,useCY*y);
530 }
531 }
532 }
533
534 void
exit_clover()535 exit_clover()
536 {
537 return;
538 }
539
540 void
draw_clover(int winno)541 draw_clover(int winno)
542 {
543 int x,y,gaaak;
544 int useCX = CX[winno] / (options.mirrors+1);
545 int useCY = CY[winno] / (options.mirrors+1);
546 int midX=useCX>>1;
547 int midY=useCY>>1;
548 int col=1; float colstep=1;
549
550 int numLines=2*useCX+2*useCY;
551 int numberToSkip= (numLines%numcolors)/4; /* skip this many per side */
552 if(numcolors>256)
553 {
554 colstep = (float)numcolors/useCX;
555 }
556 for(x=0;x<useCX;x++)
557 {
558 XDrawLine(display,window[winno],color_gcs[col],
559 useCX-x,useCY,midX,midY);
560 if(numberToSkip)
561 gaaak=x%(useCX/numberToSkip);
562 else
563 gaaak=1;
564 if(gaaak)
565 {
566 col+=colstep;
567 if(col>numcolors-1)
568 col=1;
569 }
570 }
571 for(y=0;y<useCY;y++)
572 {
573 XDrawLine(display,window[winno],color_gcs[col],
574 0,useCY-y,midX,midY);
575 if(numberToSkip)
576 gaaak=y%(useCY/numberToSkip);
577 else
578 gaaak=1;
579 if(gaaak)
580 {
581 col+=colstep;
582 if(col>numcolors-1)
583 col=1;
584 }
585 }
586 for(x=0;x<useCX;x++)
587 {
588 XDrawLine(display,window[winno],color_gcs[col],
589 x,0,midX,midY);
590 if(numberToSkip)
591 gaaak=x%(useCX/numberToSkip);
592 else
593 gaaak=1;
594
595 if(gaaak)
596 {
597 col+=colstep;
598 if(col>numcolors-1)
599 col=1;
600 }
601 }
602 for(y=0;y<useCY;y++)
603 {
604 XDrawLine(display,window[winno],color_gcs[col],
605 useCX,y,midX,midY);
606 if(numberToSkip)
607 gaaak=y%(useCY/numberToSkip);
608 else
609 gaaak=1;
610 if(gaaak)
611 {
612 col+=colstep;
613 if(col>numcolors-1)
614 col=1;
615 }
616 }
617
618 if(options.mirrors)
619 {
620 for(x=0;x<=(options.mirrors+1);x++)
621 for(y=0;y<=(options.mirrors+1);y++)
622 {
623 XCopyArea(display,window[winno],window[winno],color_gcs[1],
624 0,0,useCX,useCY,useCX*x,useCY*y);
625 }
626 }
627 }
628
629 void
exit_test()630 exit_test()
631 {
632 return;
633 }
634
635 void
draw_test(int winno)636 draw_test(int winno)
637 {
638 int x,y;
639 int fx,fy;
640 float ffx, ffy;
641
642 if(options.palette==3)
643 {
644 fx=fy=(int)sqrt(numcolors);
645 ffx =(float)(CX[winno]/sqrt(numcolors));
646 ffy =(float)(CY[winno]/sqrt(numcolors));
647 }
648 else
649 {
650 fx=(numcolors/6);
651 fy=6;
652 while(fy<<1<fx>>1)
653 {
654 fx>>=1;
655 fy<<=1;
656 }
657 ffx =(CX[winno]/(float)fx);
658 ffy =(CY[winno]/(float)fy);
659 }
660
661 for (x=0;x<fx;x++)
662 {
663 for (y=0;y<fy;y++)
664 {
665 XFillRectangle(display,window[winno],color_gcs[y*fx+x],
666 (int)(x*ffx),(int)(y*ffy),(unsigned int)(ffx+1),
667 (unsigned int)(ffy+1));
668 }
669 XFlush(display);
670 }
671 }
672
673 void
exit_sphere()674 exit_sphere()
675 {
676 return;
677 }
678
679 void
draw_sphere(int winno)680 draw_sphere(int winno)
681 {
682 int x2=rndm(CX[winno]);
683 int y2=rndm(CY[winno]);
684 int x1=rndm(CX[winno]);
685 int y1=rndm(CY[winno]);
686
687 HC[winno]=rndm(numcolors);
688
689 while((abs(x1-x2)>1)&&(abs(y1-y2)>1))
690 {
691 XFillPolygon(display,window[winno],color_gcs[HC[winno]],
692 make_circle(x1, y1, x2, y2),
693 33,Nonconvex,CoordModeOrigin);
694 if(x1-x2<0)
695 { x1++; x2--; }
696 else if (x1-x2>0)
697 { x1--; x2++; }
698 if(y1-y2<0)
699 { y1++; y2--; }
700 else if (y1-y2>0)
701 { y1--; y2++; }
702 HC[winno]=(HC[winno]+1)%numcolors;
703 if(HC[winno]==0) HC[winno]=1;
704 }
705 }
706
707
708 void
exit_off()709 exit_off()
710 {
711 return;
712 }
713
714 void
draw_off(int winno)715 draw_off(int winno)
716 {
717 int x,i;
718 unsigned int fifthCX,seventhCX,quarterCY;
719 XGCValues values;
720 /* White, Yellow, Cyan, Green, Magenta, Red, Blue */
721 /* alloc, numcol/6, numcol/2, numcol/3, 5*numcol/6, 1, 2*numcol/3 */
722 int foob[8];
723 foob[0]= numcolors/12;
724 foob[1]= numcolors/6;
725 foob[2]= numcolors/2;
726 foob[3]= numcolors/3;
727 foob[4]= 5*numcolors/6;
728 foob[5]= 1;
729 foob[6]= 2*numcolors/3;
730
731 /* make an Orange into a White*/
732 values.foreground=StrColor("white",WhitePixel(display,screen));
733 XChangeGC(display,color_gcs[numcolors/12],GCForeground,&values);
734
735 /* and a blue-purple into a Navy */
736 values.foreground=StrColor("navy blue",BlackPixel(display,screen));
737 XChangeGC(display,color_gcs[9*numcolors/12],GCForeground,&values);
738 /* and another blue becomes a medium blue */
739 values.foreground=StrColor("medium blue",BlackPixel(display,screen));
740 XChangeGC(display,color_gcs[1+(9*numcolors/12)],GCForeground,&values);
741
742 fifthCX=(unsigned int)((float)CX[winno]/5);
743 quarterCY=(unsigned int)((float)(CY[winno]/4));
744 seventhCX=(unsigned int)((float)(CX[winno]/7));
745
746 for(i=0,x=0;i<7;i++,x++)
747 {
748 XFillRectangle(display,window[winno],color_gcs[foob[i]],
749 x*seventhCX, 0, seventhCX,
750 (unsigned int)(3*quarterCY));
751 }
752
753
754 /* and the squares across the bottom */
755 XFillRectangle(display,window[winno],color_gcs[9*numcolors/12],
756 0,(3*quarterCY), fifthCX, quarterCY);
757
758 XFillRectangle(display,window[winno],color_gcs[numcolors/12],
759 fifthCX,(3*quarterCY), fifthCX, quarterCY);
760
761 XFillRectangle(display,window[winno],color_gcs[1+(9*numcolors/12)],
762 2*fifthCX,3*quarterCY,fifthCX,quarterCY);
763 }
764
765 void
draw_sunflower(int winno)766 draw_sunflower(int winno)
767 {
768 int x,y;
769 int xcenter = CX[winno]>>1;
770 int ycenter = CY[winno]>>1;
771 for(x=0;x<CX[winno];x++)
772 for(y=0;y<CY[winno];y++)
773 {
774 unsigned int d = math_dist(x,y,xcenter,ycenter);
775 /* int angle = (int)(RecttoPolar(dx, dy)*options.number); */
776 int colr =(int)(d* RecttoPolar(x-xcenter,y-ycenter));
777 while(colr<0) colr+=numcolors;
778 while(colr>=numcolors) colr-=numcolors;
779 fprintf(stderr,"colr = %d x = %d y = %d\n",colr,x,y);
780 XDrawPoint(display,window[winno],color_gcs[colr],x,y);
781 }
782 return;
783 }
784
785 void
exit_sunflower(int winno)786 exit_sunflower(int winno)
787 {
788 return;
789 }
790
791 void
draw_flush(int winno)792 draw_flush(int winno)
793 {
794 int i,x,y;
795 /* occasionally drop new stuff in */
796
797 if(!rndm(4000))
798 {
799 int color = rndm(numcolors);
800 int xsize = rndm(CX[winno]>>3);
801 int ysize = rndm(CY[winno]>>3);
802 XFillRectangle(display,window[winno],color_gcs[color],
803 rndm(CX[winno]),rndm(CY[winno]),
804 xsize,ysize);
805 }
806
807 /* start from the center, and XCopyArea stuff toward the middle, with a
808 counter-clockwise spin (maybe clockwise if we find a domain name
809 from the southern hemisphere :)*/
810 for(i=0;i<20;i++)
811 {
812 int dx,dy,dist;
813 double angle;
814 XPoint newpt;
815 x=rndm(CX[winno]); y=rndm(CY[winno]);
816 dx = x - (CX[winno]>>1);
817 dy = y - (CY[winno]>>1);
818 dist = math_dist(0,0,dx, dy);
819 angle = (RecttoPolar(dx, dy));
820 dist -= 5;
821 angle += M_PI/64;
822 newpt = PolartoRect(dist,angle);
823 XCopyArea(display,window[winno],window[winno],color_gcs[0],
824 x,y,3,3,newpt.x+(CX[winno]>>1),newpt.y+(CY[winno]>>1));
825 }
826 return;
827 }
828
829 void
init_flush(int winno)830 init_flush(int winno)
831 {
832 int i;
833 for(i=0;i<60;i++)
834 {
835 int color = rndm(numcolors);
836 int xsize = rndm(CX[winno]>>1);
837 int ysize = rndm(CY[winno]>>1);
838 XFillRectangle(display,window[winno],color_gcs[color],
839 rndm(CX[winno]),rndm(CY[winno]),
840 xsize,ysize);
841 }
842 return;
843 }
844
845 void
exit_flush(int winno)846 exit_flush(int winno)
847 {
848 return;
849 }
850
851 void
draw_blur(int winno)852 draw_blur(int winno)
853 {
854 int i,x,y;
855 /* occasionally drop new stuff in */
856
857 if(!rndm(4000))
858 {
859 int color = rndm(numcolors);
860 int xsize = rndm(CX[winno]>>3);
861 int ysize = rndm(CY[winno]>>3);
862 XFillRectangle(display,window[winno],color_gcs[color],
863 rndm(CX[winno]),rndm(CY[winno]),
864 xsize,ysize);
865 }
866
867 for(i=0;i<20;i++)
868 {
869 x=rndm(CX[winno]); y=rndm(CY[winno]);
870 XCopyArea(display,window[winno],window[winno],color_gcs[0],
871 x,y,2,2,x+(rndm(5))-2,y+(rndm(5))-2);
872 }
873 return;
874 }
875
876 void
init_blur(int winno)877 init_blur(int winno)
878 {
879 int i;
880 for(i=0;i<60;i++)
881 {
882 int color = rndm(numcolors);
883 int xsize = rndm(CX[winno]>>1);
884 int ysize = rndm(CY[winno]>>1);
885 XFillRectangle(display,window[winno],color_gcs[color],
886 rndm(CX[winno]),rndm(CY[winno]),
887 xsize,ysize);
888 }
889 return;
890 }
891
892 void
exit_blur(int winno)893 exit_blur(int winno)
894 {
895 return;
896 }
897
898 #ifdef IMAGE
899 void
init_munch(int winno)900 init_munch(int winno)
901 {
902 im = XGetImage(display,window[winno],0,0,CX[winno],CY[winno],~0L,ZPixmap);
903 if(im==NULL)
904 {
905 fprintf(stderr, "Couldn't create Image. Exiting\n");
906 exit(1);
907 }
908 }
909
910 void
exit_munch()911 exit_munch()
912 {
913 XDestroyImage(im);
914 }
915
916
draw_munch(int winno,int spoo)917 void draw_munch(int winno,int spoo)
918 {
919 int x=0;
920 int foo;
921
922 for(x=0;x<CX[winno];x++)
923 {
924 foo=XGetPixel(im,x,(x^spoo)%CY[winno])+1;
925 if(foo==0||foo>numcolors) foo=1;
926 XPutPixel(im,x,(x^spoo++)%CY[winno],foo);
927 }
928 XPutImage(display,window[winno],color_gcs[0],im,0,0,0,0,CX[winno],CY[winno]);
929 }
930 #else
931 void
init_munch(int winno)932 init_munch(int winno)
933 {
934
935 }
936
937 void
exit_munch()938 exit_munch()
939 {
940
941 }
942
943 void
draw_munch(int winno,int spoo)944 draw_munch(int winno,int spoo)
945 {
946
947 }
948
949 #endif
950