+
+struct _fringe;
+
+typedef struct _circle {
+ int r; /* radius */
+ double x, y; /* position */
+ double dx, dy; /* velocity */
+
+ int visible; /* default visibility */
+ struct _fringe *lo, *hi; /* lo and hi fringes */
+
+ int ni; /* number of intersections */
+ int *i; /* sorted intersection list */
+ } circle;
+
+typedef struct _fringe {
+ struct _fringe *l, *r; /* left and right children for splay trees */
+
+ circle *c; /* associated circle */
+ int side; /* 0 for lo, 1 for hi */
+
+ int mni; /* size of intersection array */
+ int ni; /* number of intersections */
+ int *i; /* sorted intersection list */
+ } fringe;
+
+
+typedef struct _event {
+ struct _event *l, *r; /* left and right children for splay tree */
+
+ int kind; /* type of event */
+ double x, y; /* position */
+ fringe *lo, *hi; /* fringes */
+ } event;
+
+
+struct state {
+ Display *dpy;
+ Window window;
+
+ double event_cut_y;
+
+ double fringe_start_cut_x;
+ double fringe_start_cut_y;
+
+ double fringe_double_cut_x;
+ double fringe_double_cut_y;
+ fringe *fringe_double_cut_lo;
+ fringe *fringe_double_cut_hi;
+
+ int arc_buffer_count;
+ XArc arc_buffer[ARC_BUFFER_SIZE];
+
+ Bool dbuf;
+ XColor *colors;
+ XGCValues gcv;
+ GC erase_gc, draw_gc;
+ XWindowAttributes xgwa;
+ Pixmap b, ba, bb; /* double-buffering pixmap */
+
+#ifdef HAVE_DOUBLE_BUFFER_EXTENSION
+ XdbeBackBuffer backb;
+#endif /* HAVE_DOUBLE_BUFFER_EXTENSION */
+
+ int count, delay, ncolors, colorspeed, color_index, flags, iterations;
+ int color_iterations;
+ circle *circles;
+};
+
+typedef int (*cut)(struct state *, tree*); /* cut x is <, =, or > 0 given a <, =, or > x for some a */
+
+
+
+/******** splaying code */