1 /* -*- Mode: C; tab-width: 4 -*- */
2 /* apollonian --- Apollonian Circles */
4 #if !defined( lint ) && !defined( SABER )
5 static const char sccsid[] = "@(#)apollonian.c 5.02 2001/07/01 xlockmore";
9 * Copyright (c) 2000, 2001 by Allan R. Wilks <allan@research.att.com>.
11 * Permission to use, copy, modify, and distribute this software and its
12 * documentation for any purpose and without fee is hereby granted,
13 * provided that the above copyright notice appear in all copies and that
14 * both that copyright notice and this permission notice appear in
15 * supporting documentation.
17 * This file is provided AS IS with no warranties of any kind. The author
18 * shall have no liability with respect to the infringement of copyrights,
19 * trade secrets or any patents by this file or any part thereof. In no
20 * event will the author be liable for any lost revenue or profits or
21 * other special, indirect and consequential damages.
23 * radius r = 1 / c (curvature)
25 * Descartes Circle Theorem: (a, b, c, d are curvatures of tangential circles)
26 * Let a, b, c, d be the curvatures of for mutually (externally) tangent
27 * circles in the plane. Then
28 * a^2 + b^2 + c^2 + d^2 = (a + b + c + d)^2 / 2
30 * Complex Descartes Theorem: If the oriented curvatues and (complex) centers
31 * of an oriented Descrates configuration in the plane are a, b, c, d and
32 * w, x, y, z respectively, then
33 * a^2*w^2 + b^2*x^2 + c^2*y^2 + d^2*z^2 = (aw + bx + cy + dz)^2 / 2
34 * In addition these quantities satisfy
35 * a^2*w + b^2*x + c^2*y + d^2*z = (aw + bx + cy + dz)(a + b + c + d) / 2
37 * Enumerate root integer Descartes quadruples (a,b,c,d) satisfying the
38 * Descartes condition:
39 * 2(a^2+b^2+c^2+d^2) = (a+b+c+d)^2
40 * i.e., quadruples for which no application of the "pollinate" operator
41 * z <- 2(a+b+c+d) - 3*z,
42 * where z is in {a,b,c,d}, gives a quad of strictly smaller sum. This
43 * is equivalent to the condition:
44 * sum(a,b,c,d) >= 2*max(a,b,c,d)
45 * which, because of the Descartes condition, is equivalent to
46 * sum(a^2,b^2,c^2,d^2) >= 2*max(a,b,c,d)^2
53 * 25-Jun-2001: Converted from C and Postscript code by David Bagley
54 * Original code by Allan R. Wilks <allan@research.att.com>.
56 * From Circle Math Science News April 21, 2001 VOL. 254-255
57 * http://www.sciencenews.org/20010421/toc.asp
58 * Apollonian Circle Packings Assorted papers from Ronald L Graham,
59 * Jeffrey Lagarias, Colin Mallows, Allan Wilks, Catherine Yan
60 * http://front.math.ucdavis.edu/math.NT/0009113
61 * http://front.math.ucdavis.edu/math.MG/0101066
62 * http://front.math.ucdavis.edu/math.MG/0010298
63 * http://front.math.ucdavis.edu/math.MG/0010302
64 * http://front.math.ucdavis.edu/math.MG/0010324
68 #define MODE_apollonian
69 #define PROGCLASS "Apollonian"
70 #define HACK_INIT init_apollonian
71 #define HACK_DRAW draw_apollonian
72 #define apollonian_opts xlockmore_opts
73 #define DEFAULTS "*delay: 1000000 \n" \
77 #include "xlockmore.h" /* in xscreensaver distribution */
79 #else /* STANDALONE */
80 #include "xlock.h" /* in xlockmore distribution */
81 #endif /* STANDALONE */
83 #ifdef MODE_apollonian
85 #define DEF_ALTGEOM "True"
86 #define DEF_LABEL "True"
91 static XrmOptionDescRec opts[] =
93 {(char *) "-altgeom", (char *) ".apollonian.altgeom", XrmoptionNoArg, (caddr_t) "on"},
94 {(char *) "+altgeom", (char *) ".apollonian.altgeom", XrmoptionNoArg, (caddr_t) "off"},
95 {(char *) "-label", (char *) ".apollonian.label", XrmoptionNoArg, (caddr_t) "on"},
96 {(char *) "+label", (char *) ".apollonian.label", XrmoptionNoArg, (caddr_t) "off"},
98 static argtype vars[] =
100 {(caddr_t *) & altgeom, (char *) "altgeom", (char *) "AltGeom", (char *) DEF_ALTGEOM, t_Bool},
101 {(caddr_t *) & label, (char *) "label", (char *) "Label", (char *) DEF_LABEL, t_Bool},
103 static OptionStruct desc[] =
105 {(char *) "-/+altgeom", (char *) "turn on/off alternate geometries (off euclidean space, on includes spherical and hyperbolic)"},
106 {(char *) "-/+label", (char *) "turn on/off alternate space and number labeling"},
109 ModeSpecOpt apollonian_opts =
110 {sizeof opts / sizeof opts[0], opts, sizeof vars / sizeof vars[0], vars, desc};
113 extern XFontStruct *getFont(Display * display);
117 ModStruct apollonian_description =
118 {"apollonian", "init_apollonian", "draw_apollonian", "release_apollonian",
119 "init_apollonian", "init_apollonian", (char *) NULL, &apollonian_opts,
120 1000000, 64, 20, 1, 64, 1.0, "",
121 "Shows Apollonian Circles", 0, NULL};
127 } apollonian_quadruple;
130 double e; /* euclidean bend */
131 double s; /* spherical bend */
132 double h; /* hyperbolic bend */
133 double x, y; /* euclidean bend times euclidean position */
136 euclidean = 0, spherical, hyperbolic
139 const char * space_string[] = {
146 Generate Apollonian packing starting with a quadruple of circles.
147 The four input lines each contain the 5-tuple (e,s,h,x,y) representing
148 the circle with radius 1/e and center (x/e,y/e). The s and h is propagated
149 like e, x and y, but can differ from e so as to represent different
150 geometries, spherical and hyperbolic, respectively. The "standard" picture,
151 for example (-1, 2, 2, 3), can be labeled for the three geometries.
152 Origins of circles z1, z2, z3, z4
155 c * z3 = (q123 + a * i)^2/(a*(a+b)) where q123 = sqrt(a*b+a*c+b*c)
156 d * z4 = (q124 + a * i)^2/(a*(a+b)) where q124 = q123 - a - b
157 If (e,x,y) represents the Euclidean circle (1/e,x/e,y/e) (so that e is
158 the label in the standard picture) then the "spherical label" is
159 (e^2+x^2+y^2-1)/(2*e) (an integer!) and the "hyperbolic label", is
160 calulated by h + s = e.
162 circle examples[][4] = {
163 { /* double semi-bounded */
176 { /* next simplest */
177 {-2, -1, -1, 0.0, 0},
183 {-3, -2, -1, 0.0, 0},
184 { 4, 3, 1, 1.0 / 3.0, 0},
186 {13, 8, 5, -8.0 / 3.0, 2}
189 {-3, -2, -1, 0.0, 0},
190 { 5, 4, 1, 2.0 / 3.0, 0},
191 { 8, 5, 3, -4.0 / 3.0, -1},
192 { 8, 5, 3, -4.0 / 3.0, 1}
195 {-4, -3, -1, 0.00, 0},
197 {20, 13, 7, -4.00, 0},
198 {21, 14, 7, -3.75, 2}
201 {-4, -2, -2, 0.0, 0},
203 { 9, 5, 4, -0.75, -1},
207 {-5, -4, -1, 0.0, 0},
209 {18, 13, 5, -2.4, -1},
213 {-6, -5, -1, 0.0, 0},
214 { 7, 6, 1, 1.0 / 6.0, 0},
215 {42, 31, 11, -6.0, 0},
216 {43, 32, 11, -35.0 / 6.0, 2}
219 {-6, -3, -3, 0.0, 0},
220 {10, 5, 5, 2.0 / 3.0, 0},
222 {19, 10, 9, -5.0 / 6.0, 2}
225 {-6, -5, -1, 0.0, 0.0},
226 {11, 10, 1, 5.0 / 6.0, 0.0},
227 {14, 11, 3, -16.0 / 15.0, -0.8},
228 {15, 12, 3, -0.9, 1.2}
231 /* Non integer stuff */
232 #define DELTA 2.154700538 /* ((3+2*sqrt(3))/3) */
233 { /* 3 fold symmetric bounded (x, y calculated later) */
234 { -1, -1, -1, 0.0, 0.0},
235 {DELTA, DELTA, DELTA, 1.0, 0.0},
236 {DELTA, DELTA, DELTA, 1.0, -1.0},
237 {DELTA, DELTA, DELTA, -1.0, 1.0}
239 { /* semi-bounded (x, y calculated later) */
240 #define ALPHA 2.618033989 /* ((3+sqrt(5))/2) */
241 { 1.0, 1.0, 1.0, 0, 0},
242 { 0.0, 0.0, 0.0, 0, -1},
243 {1.0/(ALPHA*ALPHA), 1.0/(ALPHA*ALPHA), 1.0/(ALPHA*ALPHA), -1, 0},
244 { 1.0/ALPHA, 1.0/ALPHA, 1.0/ALPHA, -1, 0}
246 { /* unbounded (x, y calculated later) */
247 /* #define PHI 1.618033989 *//* ((1+sqrt(5))/2) */
248 #define BETA 2.890053638 /* (PHI+sqrt(PHI)) */
249 { 1.0, 1.0, 1.0, 0, 0},
250 {1.0/(BETA*BETA*BETA), 1.0/(BETA*BETA*BETA), 1.0/(BETA*BETA*BETA), 1, 0},
251 { 1.0/(BETA*BETA), 1.0/(BETA*BETA), 1.0/(BETA*BETA), 1, 0},
252 { 1.0/BETA, 1.0/BETA, 1.0/BETA, 1, 0}
256 #define PREDEF_CIRCLE_GAMES (sizeof (examples) / (4 * sizeof (circle)))
289 circle c1, c2, c3, c4;
293 apollonian_quadruple *quad;
301 static apollonianstruct *apollonians = (apollonianstruct *) NULL;
303 #define FONT_HEIGHT 19
304 #define FONT_WIDTH 15
305 #define FONT_LENGTH 20
307 #define K 2.15470053837925152902 /* 1+2/sqrt(3) */
308 #define MAXBEND 100 /* Do not want configurable by user since it will take too
309 much time if increased. */
331 y = (int) (sqrt((double) n) + 0.5);
332 return ((n == y*y) ? y : -1);
336 dquad(int n, apollonian_quadruple *quad)
339 int counter = 0, B, C;
341 for (a = 0; a < MAXBEND; a++) {
343 for (b = a + 1; b <= B; b++) {
344 C = (int) (((a + b) * (a + b)) / (4.0 * (b - a)));
345 for (c = b; c <= C; c++) {
346 d = isqrt(b*c-a*(b+c));
347 if (d >= 0 && (gcd(a,gcd(b,c)) <= 1)) {
348 quad[counter].a = -a;
351 quad[counter].d = -a+b+c-2*d;
352 if (++counter >= n) {
359 (void) printf("found only %d below maximum bend of %d\n",
361 for (; counter < n; counter++) {
362 quad[counter].a = -1;
371 * Given a Descartes quadruple of bends (a,b,c,d), with a<0, find a
372 * quadruple of circles, represented by (bend,bend*x,bend*y), such
373 * that the circles have the given bends and the bends times the
374 * centers are integers.
376 * This just performs an exaustive search, assuming that the outer
377 * circle has center in the unit square.
379 * It is always sufficient to look in {(x,y):0<=y<=x<=1/2} for the
380 * center of the outer circle, but this may not lead to a packing
381 * that can be labelled with integer spherical and hyperbolic labels.
382 * To effect the smaller search, replace FOR(a) with
384 * for (pa = ea/2; pa <= 0; pa++) for (qa = pa; qa <= 0; qa++)
387 #define For(v,l,h) for (v = l; v <= h; v++)
388 #define FOR(z) For(p##z,lop##z,hip##z) For(q##z,loq##z,hiq##z)
389 #define H(z) ((e##z*e##z+p##z*p##z+q##z*q##z)%2)
390 #define UNIT(z) ((abs(e##z)-1)*(abs(e##z)-1) >= p##z*p##z+q##z*q##z)
391 #define T(z,w) is_tangent(e##z,p##z,q##z,e##w,p##w,q##w)
392 #define LO(r,z) lo##r##z = iceil(e##z*(r##a+1),ea)-1
393 #define HI(r,z) hi##r##z = iflor(e##z*(r##a-1),ea)-1
394 #define B(z) LO(p,z); HI(p,z); LO(q,z); HI(q,z)
397 is_quad(int a, int b, int c, int d)
402 return 2*(a*a+b*b+c*c+d*d) == s*s;
406 is_tangent(int e1, int p1, int q1, int e2, int p2, int q2)
413 return dx*dx + dy*dy == s*s;
422 (void) printf("iflor: b = 0\n");
428 return ((a<0)^(b<0)) ? -q-1 : q;
437 (void) printf("iceil: b = 0\n");
443 return ((a<0)^(b<0)) ? -q : 1+q;
447 geom(int geometry, int e, int p, int q)
449 int g = (geometry == spherical) ? -1 :
450 (geometry == hyperbolic) ? 1 : 0;
453 return (e*e + (1.0 - p*p - q*q) * g) / (2.0*e);
454 (void) printf("geom: g = 0\n");
459 cquad(circle *c1, circle *c2, circle *c3, circle *c4)
464 int lopa, lopb, lopc, lopd;
465 int hipa, hipb, hipc, hipd;
466 int loqa, loqb, loqc, loqd;
467 int hiqa, hiqb, hiqc, hiqd;
474 (void) printf("ea = %d\n", ea);
475 if (!is_quad(ea,eb,ec,ed))
476 (void) printf("Error not quad %d %d %d %d\n", ea, eb, ec, ed);
481 if (H(a) && UNIT(a)) FOR(b) {
482 if (H(b) && T(a,b)) FOR(c) {
483 if (H(c) && T(a,c) && T(b,c)) FOR(d) {
484 if (H(d) && T(a,d) && T(b,d) && T(c,d)) {
485 c1->s = geom(spherical, ea, pa, qa);
486 c1->h = geom(hyperbolic, ea, pa, qa);
487 c2->s = geom(spherical, eb, pb, qb);
488 c2->h = geom(hyperbolic, eb, pb, qb);
489 c3->s = geom(spherical, ec, pc, qc);
490 c3->h = geom(hyperbolic, ec, pc, qc);
491 c4->s = geom(spherical, ed, pd, qd);
492 c4->h = geom(hyperbolic, ed, pd, qd);
501 p(ModeInfo *mi, circle c)
503 apollonianstruct *cp = &apollonians[MI_SCREEN(mi)];
509 (void) printf("c.e=%g c.s=%g c.h=%g c.x=%g c.y=%g\n",
510 c.e, c.s, c.h, c.x, c.y);
512 g = (cp->geometry == spherical) ? c.s : (cp->geometry == hyperbolic) ?
517 if (MI_NPIXELS(mi) <= 2)
518 XSetForeground(MI_DISPLAY(mi), MI_GC(mi),
521 XSetForeground(MI_DISPLAY(mi), MI_GC(mi),
522 MI_PIXEL(mi, ((int) ((g + cp->color_offset) *
523 g)) % MI_NPIXELS(mi)));
524 XDrawArc(MI_DISPLAY(mi), MI_WINDOW(mi), MI_GC(mi),
525 ((int) (cp->size * (-cp->c1.e) * (c.x - 1.0) /
526 (-2.0 * c.e) + cp->size / 2.0 + cp->offset.x)),
527 ((int) (cp->size * (-cp->c1.e) * (c.y - 1.0) /
528 (-2.0 * c.e) + cp->size / 2.0 + cp->offset.y)),
529 (int) (cp->c1.e * cp->size / c.e),
530 (int) (cp->c1.e * cp->size / c.e), 0, 23040);
533 (void) printf("%g\n", -g);
537 (void) sprintf(string, "%g", (g == 0.0) ? 0 : -g);
538 if (cp->size >= 10 * FONT_WIDTH) {
539 /* hard code these to corners */
540 XDrawString(MI_DISPLAY(mi), MI_WINDOW(mi), MI_GC(mi),
541 ((int) (cp->size * c.x / (2.0 * c.e))) + cp->offset.x,
542 ((int) (cp->size * c.y / (2.0 * c.e))) + FONT_HEIGHT,
543 string, (g == 0.0) ? 1 : ((g < 10.0) ? 2 :
544 ((g < 100.0) ? 3 : 4)));
546 if (cp->altgeom && MI_HEIGHT(mi) >= 30 * FONT_WIDTH) {
547 XDrawString(MI_DISPLAY(mi), MI_WINDOW(mi), MI_GC(mi),
548 ((int) (cp->size * c.x / (2.0 * c.e) + cp->offset.x)),
549 ((int) (cp->size * c.y / (2.0 * c.e) + MI_HEIGHT(mi) -
550 FONT_HEIGHT / 2)), space_string[cp->geometry],
551 strlen(space_string[cp->geometry]));
555 if (MI_NPIXELS(mi) <= 2)
556 XSetForeground(MI_DISPLAY(mi), MI_GC(mi), MI_WHITE_PIXEL(mi));
558 XSetForeground(MI_DISPLAY(mi), MI_GC(mi),
559 MI_PIXEL(mi, ((int) ((g + cp->color_offset) * g)) %
562 if (c.x == 0.0 && c.y != 0.0) {
563 XDrawLine(MI_DISPLAY(mi), MI_WINDOW(mi), MI_GC(mi),
564 0, (int) ((c.y + 1.0) * cp->size / 2.0 + cp->offset.y),
566 (int) ((c.y + 1.0) * cp->size / 2.0 + cp->offset.y));
567 } else if (c.y == 0.0 && c.x != 0.0) {
568 XDrawLine(MI_DISPLAY(mi), MI_WINDOW(mi), MI_GC(mi),
569 (int) ((c.x + 1.0) * cp->size / 2.0 + cp->offset.x), 0,
570 (int) ((c.x + 1.0) * cp->size / 2.0 + cp->offset.x),
575 e = (cp->c1.e >= 0.0) ? 1.0 : -cp->c1.e;
576 XFillArc(MI_DISPLAY(mi), MI_WINDOW(mi), MI_GC(mi),
577 ((int) (cp->size * e * (c.x - 1.0) / (2.0 * c.e) +
578 cp->size / 2.0 + cp->offset.x)),
579 ((int) (cp->size * e * (c.y - 1.0) / (2.0 * c.e) +
580 cp->size / 2.0 + cp->offset.y)),
581 (int) (e * cp->size / c.e), (int) (e * cp->size / c.e),
585 (void) printf("%g\n", g);
589 if (MI_NPIXELS(mi) <= 2)
590 XSetForeground(MI_DISPLAY(mi), MI_GC(mi), MI_BLACK_PIXEL(mi));
592 XSetForeground(MI_DISPLAY(mi), MI_GC(mi),
593 MI_PIXEL(mi, ((int) ((g + cp->color_offset) * g) +
594 MI_NPIXELS(mi) / 2) % MI_NPIXELS(mi)));
595 g_width = (g < 10.0) ? 1: ((g < 100.0) ? 2 : 3);
596 if (c.e < e * cp->size / (FONT_LENGTH + 5 * g_width) && g < 1000.0) {
597 (void) sprintf(string, "%g", g);
598 XDrawString(MI_DISPLAY(mi), MI_WINDOW(mi), MI_GC(mi),
599 ((int) (cp->size * e * c.x / (2.0 * c.e) +
600 cp->size / 2.0 + cp->offset.x)) -
601 g_width * FONT_WIDTH / 2,
602 ((int) (cp->size * e * c.y / (2.0 * c.e) +
603 cp->size / 2.0 + cp->offset.y)) +
611 f(ModeInfo *mi, circle c1, circle c2, circle c3, circle c4)
613 apollonianstruct *cp = &apollonians[MI_SCREEN(mi)];
614 int e = (int) ((cp->c1.e >= 0.0) ? 1.0 : -cp->c1.e);
617 c.e = 2*(c1.e+c2.e+c3.e) - c4.e;
618 c.s = 2*(c1.s+c2.s+c3.s) - c4.s;
619 c.h = 2*(c1.h+c2.h+c3.h) - c4.h;
620 c.x = 2*(c1.x+c2.x+c3.x) - c4.x;
621 c.y = 2*(c1.y+c2.y+c3.y) - c4.y;
622 if (c.e > cp->size * e || c.x / c.e > BIG || c.y / c.e > BIG ||
623 c.x / c.e < -BIG || c.y / c.e < -BIG)
626 f(mi, c2, c3, c, c1);
627 f(mi, c1, c3, c, c2);
628 f(mi, c1, c2, c, c3);
632 free_apollonian(Display *display, apollonianstruct *cp)
634 if (cp->quad != NULL) {
635 (void) free((void *) cp->quad);
636 cp->quad = (apollonian_quadruple *) NULL;
639 if (cp->gc != None) {
640 XFreeGC(display, cp->gc);
643 if (cp->font != None) {
644 XFreeFont(display, cp->font);
652 randomize_c(int randomize, circle * c)
669 init_apollonian(ModeInfo * mi)
671 apollonianstruct *cp;
674 if (apollonians == NULL) {
675 if ((apollonians = (apollonianstruct *) calloc(MI_NUM_SCREENS(mi),
676 sizeof (apollonianstruct))) == NULL)
679 cp = &apollonians[MI_SCREEN(mi)];
681 cp->size = MAX(MIN(MI_WIDTH(mi), MI_HEIGHT(mi)) - 1, 1);
682 cp->offset.x = (MI_WIDTH(mi) - cp->size) / 2;
683 cp->offset.y = (MI_HEIGHT(mi) - cp->size) / 2;
684 cp->color_offset = NRAND(MI_NPIXELS(mi));
687 if (cp->font == None) {
688 if ((cp->font = getFont(MI_DISPLAY(mi))) == None)
693 cp->altgeom = cp->label && altgeom;
695 if (cp->quad == NULL) {
696 cp->count = ABS(MI_COUNT(mi));
697 if ((cp->quad = (apollonian_quadruple *) malloc(cp->count *
698 sizeof (apollonian_quadruple))) == NULL) {
701 dquad(cp->count, cp->quad);
703 cp->game = NRAND(PREDEF_CIRCLE_GAMES + cp->count);
704 cp->geometry = (cp->game && cp->altgeom) ? NRAND(3) : 0;
706 if (cp->game < PREDEF_CIRCLE_GAMES) {
707 cp->c1 = examples[cp->game][0];
708 cp->c2 = examples[cp->game][1];
709 cp->c3 = examples[cp->game][2];
710 cp->c4 = examples[cp->game][3];
711 /* do not label non int */
712 cp->label = cp->label && (cp->c4.e == (int) cp->c4.e);
713 } else { /* uses results of dquad, all int */
714 i = cp->game - PREDEF_CIRCLE_GAMES;
715 cp->c1.e = cp->quad[i].a;
716 cp->c2.e = cp->quad[i].b;
717 cp->c3.e = cp->quad[i].c;
718 cp->c4.e = cp->quad[i].d;
720 cquad(&(cp->c1), &(cp->c2), &(cp->c3), &(cp->c4));
727 if (cp->c1.e == 0.0 || cp->c1.e == -cp->c2.e)
731 cp->c2.x = -(cp->c1.e + cp->c2.e) / cp->c1.e;
733 q123 = sqrt(cp->c1.e * cp->c2.e + cp->c1.e * cp->c3.e +
734 cp->c2.e * cp->c3.e);
736 (void) printf("q123 = %g, ", q123);
738 cp->c3.x = (cp->c1.e * cp->c1.e - q123 * q123) / (cp->c1.e *
739 (cp->c1.e + cp->c2.e));
740 cp->c3.y = -2.0 * q123 / (cp->c1.e + cp->c2.e);
741 q123 = -cp->c1.e - cp->c2.e + q123;
742 cp->c4.x = (cp->c1.e * cp->c1.e - q123 * q123) / (cp->c1.e *
743 (cp->c1.e + cp->c2.e));
744 cp->c4.y = -2.0 * q123 / (cp->c1.e + cp->c2.e);
746 (void) printf("q124 = %g\n", q123);
747 (void) printf("%g %g %g %g %g %g %g %g\n",
748 cp->c1.x, cp->c1.y, cp->c2.x, cp->c2.y,
749 cp->c3.x, cp->c3.y, cp->c4.x, cp->c4.y);
754 cp->c3.y = -cp->c3.y;
755 cp->c4.y = -cp->c4.y;
758 randomize_c(i, &(cp->c1));
759 randomize_c(i, &(cp->c2));
760 randomize_c(i, &(cp->c3));
761 randomize_c(i, &(cp->c4));
766 draw_apollonian(ModeInfo * mi)
768 apollonianstruct *cp;
770 if (apollonians == NULL)
772 cp = &apollonians[MI_SCREEN(mi)];
775 MI_IS_DRAWN(mi) = True;
786 f(mi, cp->c1, cp->c2, cp->c3, cp->c4);
789 f(mi, cp->c1, cp->c2, cp->c4, cp->c3);
792 f(mi, cp->c1, cp->c3, cp->c4, cp->c2);
795 f(mi, cp->c2, cp->c3, cp->c4, cp->c1);
798 if (++cp->time > MI_CYCLES(mi))
801 erase_full_window(MI_DISPLAY(mi), MI_WINDOW(mi));
802 #endif /* STANDALONE */
808 release_apollonian(ModeInfo * mi)
810 if (apollonians != NULL) {
813 for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++)
814 free_apollonian(MI_DISPLAY(mi), &apollonians[screen]);
815 (void) free((void *) apollonians);
816 apollonians = (apollonianstruct *) NULL;
820 #endif /* MODE_apollonian */