static Bool draw_state(ModeInfo * mi, int state) { dragonstruct *dp = &dragons[MI_SCREEN(mi)]; Display *display = MI_DISPLAY(mi); GC gc; CellList *current; if (!state) { XSetForeground(display, MI_GC(mi), MI_WHITE_PIXEL(mi)); gc = MI_GC(mi); } else if (state == 1) { XSetForeground(display, MI_GC(mi), MI_BLACK_PIXEL(mi)); gc = MI_GC(mi); } else if (MI_NPIXELS(mi) > 2) { XSetForeground(display, MI_GC(mi), dp->color); gc = MI_GC(mi); } else { XGCValues gcv; gcv.stipple = dp->graypix; gcv.foreground = MI_WHITE_PIXEL(mi); gcv.background = MI_BLACK_PIXEL(mi); XChangeGC(display, dp->stippledGC, GCStipple | GCForeground | GCBackground, &gcv); gc = dp->stippledGC; } { /* Draw right away, slow */ current = dp->cellList[state]; while (current) { int col, row, ccol, crow; col = current->pt.x; row = current->pt.y; ccol = 2 * col + !(row & 1), crow = 2 * row; if (dp->vertical) { dp->hexagon[0].x = dp->xb + ccol * dp->xs; dp->hexagon[0].y = dp->yb + crow * dp->ys; } else { dp->hexagon[0].y = dp->xb + ccol * dp->xs; dp->hexagon[0].x = dp->yb + crow * dp->ys; } if (dp->xs == 1 && dp->ys == 1) XDrawPoint(display, MI_WINDOW(mi), gc, dp->hexagon[0].x, dp->hexagon[0].y); else XFillPolygon(display, MI_WINDOW(mi), gc, dp->hexagon, 6, Convex, CoordModePrevious); current = current->next; } } XFlush(MI_DISPLAY(mi)); return True; }
static void drawtruchet(ModeInfo * mi, int col, int row, unsigned char color, unsigned char truchetstate) { antfarmstruct *ap = &antfarms[MI_SCREEN(mi)]; if (!color) XSetForeground(MI_DISPLAY(mi), MI_GC(mi), MI_WHITE_PIXEL(mi)); else if (MI_NPIXELS(mi) > 2 || color > ap->ncolors / 2) XSetForeground(MI_DISPLAY(mi), MI_GC(mi), MI_BLACK_PIXEL(mi)); else XSetForeground(MI_DISPLAY(mi), MI_GC(mi), MI_WHITE_PIXEL(mi)); truchetcell(mi, col, row, truchetstate); }
void reserveColors(ModeInfo * mi, Colormap cmap, unsigned long *black) { Display *display = MI_DISPLAY(mi); XColor blackcolor, whitecolor; blackcolor.flags = DoRed | DoGreen | DoBlue; blackcolor.pixel = MI_BLACK_PIXEL(mi); blackcolor.red = 0; blackcolor.green = 0; blackcolor.blue = 0; whitecolor.flags = DoRed | DoGreen | DoBlue; whitecolor.pixel = MI_WHITE_PIXEL(mi); whitecolor.red = 0xFFFF; whitecolor.green = 0xFFFF; whitecolor.blue = 0xFFFF; /* If they fail what should I do? */ (void) XAllocColor(display, cmap, &blackcolor); (void) XAllocColor(display, cmap, &whitecolor); *black = blackcolor.pixel; #if 0 { XColor bgcolor, fgcolor; bgcolor.pixel = MI_BG_PIXEL(mi); fgcolor.pixel = MI_FG_PIXEL(mi); XQueryColor(display, cmap, &bgcolor); XQueryColor(display, cmap, &fgcolor); (void) XAllocColor(display, cmap, &bgcolor); (void) XAllocColor(display, cmap, &fgcolor); } #endif }
static void drawcell(ModeInfo * mi, int col, int row, unsigned char color) { antfarmstruct *ap = &antfarms[MI_SCREEN(mi)]; GC gc; if (!color) { XSetForeground(MI_DISPLAY(mi), MI_GC(mi), MI_BLACK_PIXEL(mi)); gc = MI_GC(mi); } else if (MI_NPIXELS(mi) > 2) { XSetForeground(MI_DISPLAY(mi), MI_GC(mi), MI_PIXEL(mi, ap->colors[color - 1])); gc = MI_GC(mi); } else { XGCValues gcv; gcv.stipple = ap->pixmaps[color - 1]; gcv.foreground = MI_WHITE_PIXEL(mi); gcv.background = MI_BLACK_PIXEL(mi); XChangeGC(MI_DISPLAY(mi), ap->stippledGC, GCStipple | GCForeground | GCBackground, &gcv); gc = ap->stippledGC; } fillcell(mi, gc, col, row); }
static void free_mandelbrot(Display *display, mandelstruct *mp) { ModeInfo *mi = mp->mi; if (MI_IS_INSTALL(mi) && MI_NPIXELS(mi) > 2) { MI_WHITE_PIXEL(mi) = mp->whitepixel; MI_BLACK_PIXEL(mi) = mp->blackpixel; #ifndef STANDALONE MI_FG_PIXEL(mi) = mp->fg; MI_BG_PIXEL(mi) = mp->bg; #endif if (mp->colors != NULL) { if (mp->ncolors && !mp->no_colors) free_colors(display, mp->cmap, mp->colors, mp->ncolors); free(mp->colors); mp->colors = (XColor *) NULL; } if (mp->cmap != None) { XFreeColormap(display, mp->cmap); mp->cmap = None; } } if (mp->gc != None) { XFreeGC(display, mp->gc); mp->gc = None; } }
static void level1_strike(Lightning bolt, ModeInfo * mi) { Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); Storm *st = &Helga[MI_SCREEN(mi)]; GC gc = MI_GC(mi); int i; if (MI_NPIXELS(mi) > 2) /* color */ XSetForeground(display, gc, MI_PIXEL(mi, st->color)); else XSetForeground(display, gc, MI_WHITE_PIXEL(mi)); XDrawLine(display, window, gc, bolt.end1.x - 1, bolt.end1.y, bolt.middle[0].x - 1, bolt.middle[0].y); draw_line(mi, bolt.middle, BOLT_VERTICIES, gc, -1); XDrawLine(display, window, gc, bolt.middle[BOLT_VERTICIES - 1].x - 1, bolt.middle[BOLT_VERTICIES - 1].y, bolt.end2.x - 1, bolt.end2.y); XDrawLine(display, window, gc, bolt.end1.x + 1, bolt.end1.y, bolt.middle[0].x + 1, bolt.middle[0].y); draw_line(mi, bolt.middle, BOLT_VERTICIES, gc, 1); XDrawLine(display, window, gc, bolt.middle[BOLT_VERTICIES - 1].x + 1, bolt.middle[BOLT_VERTICIES - 1].y, bolt.end2.x + 1, bolt.end2.y); for (i = 0; i < bolt.fork_number; i++) { draw_line(mi, bolt.branch[i].ForkVerticies, bolt.branch[i].num_used, gc, -1); draw_line(mi, bolt.branch[i].ForkVerticies, bolt.branch[i].num_used, gc, 1); } first_strike(bolt, mi); }
static void init_planet(ModeInfo * mi, planetstruct * planet) { Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); GC gc = MI_GC(mi); gravstruct *gp = &gravs[MI_SCREEN(mi)]; if (MI_NPIXELS(mi) > 2) planet->colors = MI_PIXEL(mi, NRAND(MI_NPIXELS(mi))); else planet->colors = MI_WHITE_PIXEL(mi); /* Initialize positions */ POS(X) = FLOATRAND(-XR, XR); POS(Y) = FLOATRAND(-YR, YR); POS(Z) = FLOATRAND(-ZR, ZR); if (POS(Z) > -ALMOST) { planet->xi = (int) ((double) gp->width * (HALF + POS(X) / (POS(Z) + DIST))); planet->yi = (int) ((double) gp->height * (HALF + POS(Y) / (POS(Z) + DIST))); } else planet->xi = planet->yi = -1; planet->ri = RADIUS; /* Initialize velocities */ VEL(X) = FLOATRAND(-VR, VR); VEL(Y) = FLOATRAND(-VR, VR); VEL(Z) = FLOATRAND(-VR, VR); /* Draw planets */ Planet(planet->xi, planet->yi); }
static void init_planet(ModeInfo * mi, planetstruct * planet) { gravstruct *gp = &gravs[MI_SCREEN(mi)]; # ifdef HAVE_JWXYZ jwxyz_XSetAntiAliasing (MI_DISPLAY(mi), MI_GC(mi), False); # endif if (MI_NPIXELS(mi) > 2) planet->colors = MI_PIXEL(mi, NRAND(MI_NPIXELS(mi))); else planet->colors = MI_WHITE_PIXEL(mi); /* Initialize positions */ POS(X) = FLOATRAND(-XR, XR); POS(Y) = FLOATRAND(-YR, YR); POS(Z) = FLOATRAND(-ZR, ZR); if (POS(Z) > -ALMOST) { planet->xi = (int) ((double) gp->width * (HALF + POS(X) / (POS(Z) + DIST))); planet->yi = (int) ((double) gp->height * (HALF + POS(Y) / (POS(Z) + DIST))); } else planet->xi = planet->yi = -1; planet->ri = RADIUS; /* Initialize velocities */ VEL(X) = FLOATRAND(-VR, VR); VEL(Y) = FLOATRAND(-VR, VR); VEL(Z) = FLOATRAND(-VR, VR); }
static void InitDrop(ModeInfo * mi, rainstruct *rp, dropstruct *drop) { /* Where does the drop fall in the pool? At least 20% of height from top and not completely at the bottom */ int yMin = MI_HEIGHT(mi) / 5; int yMax = MI_HEIGHT(mi) - ((MAX_RADIUS * 3) / 2); drop->pool.x = 0; drop->pool.y = yMin + NRAND(yMax - yMin); /* How fast does it fall? */ drop->offset.x = 5 + NRAND(5); drop->offset.y = 20 + NRAND(20); /* Where does the drop start */ drop->drop.x = NRAND(MI_WIDTH(mi)); drop->drop.height = 0; drop->drop.width = drop->drop.x + drop->offset.x; drop->drop.y = drop->drop.height + drop->offset.y; /* How large is the pool and how fast does it grow? */ drop->radius = 0; drop->radius_step = 1 + NRAND(2); drop->max_radius = (MAX_RADIUS / 2) + NRAND(MAX_RADIUS / 2); /* Colored drops? */ if (rp->colored_drops) { if (rp->base_color == 0) drop->color = MI_PIXEL(mi, NRAND(MI_NPIXELS(mi))); else drop->color = rp->base_color + (NRAND(2) == 1 ? -1 : 1) * NRAND(12); } else drop->color = MI_WHITE_PIXEL(mi); }
static void drawlissie(ModeInfo * mi, lissiestruct * lissie) { Display *display = MI_DISPLAY(mi); GC gc = MI_GC(mi); lissstruct *lp = &lisses[MI_SCREEN(mi)]; int p = (++lissie->pos) % MAXLISSIELEN; int oldp = (lissie->pos - lissie->len + MAXLISSIELEN) % MAXLISSIELEN; /* Let time go by ... */ lissie->tx += lissie->dtx; lissie->ty += lissie->dty; if (lissie->tx > 2 * M_PI) lissie->tx -= 2 * M_PI; if (lissie->ty > 2 * M_PI) lissie->ty -= 2 * M_PI; /* vary both (x/y) speeds by max. 1% */ lissie->dtx *= FLOATRAND(0.99, 1.01); lissie->dty *= FLOATRAND(0.99, 1.01); if (lissie->dtx < MINDT) lissie->dtx = MINDT; else if (lissie->dtx > MAXDT) lissie->dtx = MAXDT; if (lissie->dty < MINDT) lissie->dty = MINDT; else if (lissie->dty > MAXDT) lissie->dty = MAXDT; lissie->loc[p].x = lissie->xi + (int) (sin(lissie->tx) * lissie->rx); lissie->loc[p].y = lissie->yi + (int) (sin(lissie->ty) * lissie->ry); /* Mask */ XSetForeground(display, gc, MI_BLACK_PIXEL(mi)); Lissie(oldp); /* Redraw */ if (MI_NPIXELS(mi) > 2) { XSetForeground(display, gc, MI_PIXEL(mi, lissie->color)); if (++lissie->color >= (unsigned) MI_NPIXELS(mi)) lissie->color = 0; } else XSetForeground(display, gc, MI_WHITE_PIXEL(mi)); Lissie(p); if (lissie->redrawing) { int i; lissie->redrawpos++; /* This compensates for the changed p since the last callback. */ for (i = 0; i < REDRAWSTEP; i++) { Lissie((p - lissie->redrawpos + MAXLISSIELEN) % MAXLISSIELEN); if (++(lissie->redrawpos) >= lissie->len) { lissie->redrawing = 0; break; } } } }
/* Sets the color to the color of a dot. */ static void setdotcolor(ModeInfo * mi) { Display *display = MI_DISPLAY(mi); pacmangamestruct *pp = &pacmangames[MI_SCREEN(mi)]; XSetForeground(display, pp->stippledGC, MI_WHITE_PIXEL(mi)); }
static void drawcell(ModeInfo * mi, int col, int row, unsigned char state) { dragonstruct *dp = &dragons[MI_SCREEN(mi)]; Display *display = MI_DISPLAY(mi); GC gc; if (!state) { XSetForeground(display, MI_GC(mi), MI_WHITE_PIXEL(mi)); gc = MI_GC(mi); } else if (state == 1) { XSetForeground(display, MI_GC(mi), MI_BLACK_PIXEL(mi)); gc = MI_GC(mi); } else if (MI_NPIXELS(mi) > 2) { XSetForeground(display, MI_GC(mi), dp->color); gc = MI_GC(mi); } else { XGCValues gcv; gcv.stipple = dp->graypix; gcv.foreground = MI_WHITE_PIXEL(mi); gcv.background = MI_BLACK_PIXEL(mi); XChangeGC(display, dp->stippledGC, GCStipple | GCForeground | GCBackground, &gcv); gc = dp->stippledGC; } { int ccol = 2 * col + !(row & 1), crow = 2 * row; if (dp->vertical) { dp->hexagon[0].x = dp->xb + ccol * dp->xs; dp->hexagon[0].y = dp->yb + crow * dp->ys; } else { dp->hexagon[0].y = dp->xb + ccol * dp->xs; dp->hexagon[0].x = dp->yb + crow * dp->ys; } if (dp->xs == 1 && dp->ys == 1) XDrawPoint(display, MI_WINDOW(mi), gc, dp->hexagon[0].x, dp->hexagon[0].y); else XFillPolygon(display, MI_WINDOW(mi), gc, dp->hexagon, 6, Convex, CoordModePrevious); } }
ENTRYPOINT void draw_fadeplot (ModeInfo * mi) { Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); GC gc = MI_GC(mi); int i, j, temp; fadeplotstruct *fp; if (fadeplots == NULL) return; fp = &fadeplots[MI_SCREEN(mi)]; if (fp->stab == NULL) return; MI_IS_DRAWN(mi) = True; XSetForeground(display, gc, MI_BLACK_PIXEL(mi)); XDrawPoints(display, window, gc, fp->pts, fp->maxpts, CoordModeOrigin); if (MI_NPIXELS(mi) > 2) { XSetForeground(display, gc, MI_PIXEL(mi, fp->pix)); if (++fp->pix >= MI_NPIXELS(mi)) fp->pix = 0; } else XSetForeground(display, gc, MI_WHITE_PIXEL(mi)); temp = 0; for (j = 0; j < fp->nbstep; j++) { for (i = 0; i < fp->maxpts / fp->nbstep; i++) { fp->pts[temp].x = fp->stab[(fp->st.x + fp->speed.x * j + i * fp->step.x) % fp->angles] * fp->factor.x + fp->width / 2 - fp->min; fp->pts[temp].y = fp->stab[(fp->st.y + fp->speed.y * j + i * fp->step.y) % fp->angles] * fp->factor.y + fp->height / 2 - fp->min; temp++; } } XDrawPoints(display, window, gc, fp->pts, temp, CoordModeOrigin); fp->st.x = (fp->st.x + fp->speed.x) % fp->angles; fp->st.y = (fp->st.y + fp->speed.y) % fp->angles; fp->temps++; if ((fp->temps % (fp->angles / 2)) == 0) { fp->temps = fp->temps % fp->angles * 5; if ((fp->temps % (fp->angles)) == 0) fp->speed.y = (fp->speed.y + 1) % 30 + 1; if ((fp->temps % (fp->angles * 2)) == 0) fp->speed.x = (fp->speed.x) % 20; if ((fp->temps % (fp->angles * 3)) == 0) fp->step.y = (fp->step.y + 1) % 2 + 1; MI_CLEARWINDOW(mi); } }
/* Sets the color to the color of a wall. */ static void setwallcolor(ModeInfo * mi) { Display *display = MI_DISPLAY(mi); pacmangamestruct *pp = &pacmangames[MI_SCREEN(mi)]; if (MI_NPIXELS(mi) > 2) XSetForeground(display, pp->stippledGC, MI_PIXEL(mi, BLUE)); else XSetForeground(display, pp->stippledGC, MI_WHITE_PIXEL(mi)); }
static void drawImages(ModeInfo * mi) { Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); imagestruct *ip = &ims[MI_SCREEN(mi)]; GC gc = (message && *message) ? MI_GC(mi) : ip->bgGC; int i; MI_CLEARWINDOWCOLORMAPFAST(mi, gc, ip->black); for (i = 0; i < ip->iconcount; i++) { if (ip->icons[i].x >= 0) { if (message && *message) { if (MI_NPIXELS(mi) > 2) XSetForeground(display, gc, MI_PIXEL(mi, ip->icons[i].color)); else XSetForeground(display, gc, MI_WHITE_PIXEL(mi)); XCopyPlane(display, ip->pixmap, window, gc, 0, 0, ip->pixw, ip->pixh, ip->pixw * ip->icons[i].x + ip->image_offset.x, ip->pixh * ip->icons[i].y + ip->image_offset.y, 1L); } else if (ip->logo != NULL) { if (MI_NPIXELS(mi) <= 2) XSetForeground(display, gc, MI_WHITE_PIXEL(mi)); else if (ip->graphics_format < IS_XPM) XSetForeground(display, gc, MI_PIXEL(mi, ip->icons[i].color)); (void) XPutImage(display, window, gc, ip->logo, 0, 0, ip->pixw * ip->icons[i].x + ip->image_offset.x, ip->pixh * ip->icons[i].y + ip->image_offset.y, ip->pixw, ip->pixh); } } } }
static void random_petal(ModeInfo * mi) { petalstruct *pp = &petals[MI_SCREEN(mi)]; pp->npoints = compute_petal(pp->points, pp->lines, pp->width / 2, pp->height / 2); if (MI_NPIXELS(mi) <= 2) pp->color = MI_WHITE_PIXEL(mi); else pp->color = MI_PIXEL(mi, NRAND(MI_NPIXELS(mi))); petal(mi); }
ENTRYPOINT void init_grav(ModeInfo * mi) { Display *display = MI_DISPLAY(mi); GC gc = MI_GC(mi); unsigned char ball; gravstruct *gp; if (gravs == NULL) { if ((gravs = (gravstruct *) calloc(MI_NUM_SCREENS(mi), sizeof (gravstruct))) == NULL) return; } gp = &gravs[MI_SCREEN(mi)]; gp->width = MI_WIDTH(mi); gp->height = MI_HEIGHT(mi); gp->sr = STARRADIUS; gp->nplanets = MI_COUNT(mi); if (gp->nplanets < 0) { if (gp->planets) { (void) free((void *) gp->planets); gp->planets = (planetstruct *) NULL; } gp->nplanets = NRAND(-gp->nplanets) + 1; /* Add 1 so its not too boring */ } if (gp->planets == NULL) { if ((gp->planets = (planetstruct *) calloc(gp->nplanets, sizeof (planetstruct))) == NULL) return; } MI_CLEARWINDOW(mi); if (MI_NPIXELS(mi) > 2) gp->starcolor = MI_PIXEL(mi, NRAND(MI_NPIXELS(mi))); else gp->starcolor = MI_WHITE_PIXEL(mi); for (ball = 0; ball < (unsigned char) gp->nplanets; ball++) init_planet(mi, &gp->planets[ball]); /* Draw centrepoint */ XDrawArc(display, MI_WINDOW(mi), gc, gp->width / 2 - gp->sr / 2, gp->height / 2 - gp->sr / 2, gp->sr, gp->sr, 0, 23040); }
static void initlissie(ModeInfo * mi, lissiestruct * lissie) { lissstruct *lp = &lisses[MI_SCREEN(mi)]; int size = MI_SIZE(mi); int i; if (MI_NPIXELS(mi) > 2) lissie->color = NRAND(MI_NPIXELS(mi)); else lissie->color = MI_WHITE_PIXEL(mi); /* Initialize parameters */ if (size < -MINSIZE) lissie->ri = NRAND(MIN(-size, MAX(MINSIZE, MIN(lp->width, lp->height) / 4)) - MINSIZE + 1) + MINSIZE; else if (size < MINSIZE) { if (!size) lissie->ri = MAX(MINSIZE, MIN(lp->width, lp->height) / 4); else lissie->ri = MINSIZE; } else lissie->ri = MIN(size, MAX(MINSIZE, MIN(lp->width, lp->height) / 4)); lissie->xi = INTRAND(lp->width / 4 + lissie->ri, lp->width * 3 / 4 - lissie->ri); lissie->yi = INTRAND(lp->height / 4 + lissie->ri, lp->height * 3 / 4 - lissie->ri); lissie->rx = INTRAND(lp->width / 4, MIN(lp->width - lissie->xi, lissie->xi)) - 2 * lissie->ri; lissie->ry = INTRAND(lp->height / 4, MIN(lp->height - lissie->yi, lissie->yi)) - 2 * lissie->ri; lissie->len = INTRAND(MINLISSIELEN, MAXLISSIELEN - 1); lissie->pos = 0; lissie->redrawing = 0; lissie->tx = FLOATRAND(0, 2 * M_PI); lissie->ty = FLOATRAND(0, 2 * M_PI); lissie->dtx = FLOATRAND(MINDT, MAXDT); lissie->dty = FLOATRAND(MINDT, MAXDT); for (i = 0; i < MAXLISSIELEN; i++) lissie->loc[i].x = lissie->loc[i].y = 0; /* Draw lissie */ drawlissie(mi, lissie); }
void init_blot(ModeInfo * mi) { Display *display = MI_DISPLAY(mi); blotstruct *bp; if (blots == NULL) { if ((blots = (blotstruct *) calloc(MI_NUM_SCREENS(mi), sizeof (blotstruct))) == NULL) return; } bp = &blots[MI_SCREEN(mi)]; bp->width = MI_WIDTH(mi); bp->height = MI_HEIGHT(mi); bp->xmid = bp->width / 2; bp->ymid = bp->height / 2; bp->offset = 4; bp->ysym = (int) LRAND() & 1; bp->xsym = (bp->ysym) ? (int) LRAND() & 1 : 1; if (MI_NPIXELS(mi) > 2) bp->pix = NRAND(MI_NPIXELS(mi)); if (bp->offset <= 0) bp->offset = 3; if (MI_COUNT(mi) < 0) bp->size = NRAND(-MI_COUNT(mi) + 1); else bp->size = MI_COUNT(mi); /* Fudge the size so it takes up the whole screen */ bp->size *= (bp->width / 32 + 1) * (bp->height / 32 + 1); if (!bp->pointBuffer || bp->pointBufferSize < bp->size * sizeof (XPoint)) { if (bp->pointBuffer != NULL) free(bp->pointBuffer); bp->pointBufferSize = bp->size * sizeof (XPoint); if ((bp->pointBuffer = (XPoint *) malloc(bp->pointBufferSize)) == NULL) { return; } } MI_CLEARWINDOW(mi); XSetForeground(display, MI_GC(mi), MI_WHITE_PIXEL(mi)); bp->count = 0; }
static void free_tik_tak(Display *display, tik_takstruct *tiktak) { ModeInfo *mi = tiktak->mi; if (MI_IS_INSTALL(mi) && MI_NPIXELS(mi) > 2) { MI_WHITE_PIXEL(mi) = tiktak->whitepixel; MI_BLACK_PIXEL(mi) = tiktak->blackpixel; #ifndef STANDALONE MI_FG_PIXEL(mi) = tiktak->fg; MI_BG_PIXEL(mi) = tiktak->bg; #endif if (tiktak->colors != NULL) { if (tiktak->ncolors && !tiktak->no_colors) free_colors(display, tiktak->cmap, tiktak->colors, tiktak->ncolors); free(tiktak->colors); tiktak->colors = (XColor *) NULL; } if (tiktak->cmap != None) { XFreeColormap(display, tiktak->cmap); tiktak->cmap = None; } } if (tiktak->gc != None) { XFreeGC(display, tiktak->gc); tiktak->gc = None; } if (tiktak->object != NULL) { int i; for (i = 0; i < tiktak->num_object; i++) { tik_takobject *object0; object0 = &tiktak->object[i]; if (object0->xy1 != NULL) free(object0->xy1); if (object0->xy != NULL) free(object0->xy); } free(tiktak->object); tiktak->object = (tik_takobject *) NULL; } }
static void first_strike(Lightning bolt, ModeInfo * mi) { Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); GC gc = MI_GC(mi); int i; XSetForeground(display, gc, MI_WHITE_PIXEL(mi)); XDrawLine(display, window, gc, bolt.end1.x, bolt.end1.y, bolt.middle[0].x, bolt.middle[0].y); draw_line(mi, bolt.middle, BOLT_VERTICIES, gc, 0); XDrawLine(display, window, gc, bolt.middle[BOLT_VERTICIES - 1].x, bolt.middle[BOLT_VERTICIES - 1].y, bolt.end2.x, bolt.end2.y); for (i = 0; i < bolt.fork_number; i++) draw_line(mi, bolt.branch[i].ForkVerticies, bolt.branch[i].num_used, gc, 0); }
static void drawCell(ModeInfo * mi, int col, int row, unsigned char state) { circuitstruct *wp = &circuits[MI_SCREEN(mi)]; GC gc; if (MI_NPIXELS(mi) > 2) { gc = MI_GC(mi); XSetForeground(MI_DISPLAY(mi), gc, MI_PIXEL(mi, wp->colors[state])); } else { XGCValues gcv; gcv.stipple = wp->pixmaps[state]; gcv.foreground = MI_WHITE_PIXEL(mi); gcv.background = MI_BLACK_PIXEL(mi); XChangeGC(MI_DISPLAY(mi), wp->stippledGC, GCStipple | GCForeground | GCBackground, &gcv); gc = wp->stippledGC; } fillcell(mi, gc, col, row); }
ENTRYPOINT void draw_sierpinski(ModeInfo * mi) { Display *display = MI_DISPLAY(mi); GC gc = MI_GC(mi); XPoint *xp[MAXCORNERS]; int i, v; sierpinskistruct *sp; if (tris == NULL) return; sp = &tris[MI_SCREEN(mi)]; if (sp->pointBuffer[0] == NULL) return; MI_IS_DRAWN(mi) = True; if (MI_NPIXELS(mi) <= 2) XSetForeground(display, gc, MI_WHITE_PIXEL(mi)); for (i = 0; i < sp->corners; i++) xp[i] = sp->pointBuffer[i]; for (i = 0; i < sp->total_npoints; i++) { v = NRAND(sp->corners); sp->px = (sp->px + sp->vertex[v].x) / 2; sp->py = (sp->py + sp->vertex[v].y) / 2; xp[v]->x = sp->px; xp[v]->y = sp->py; xp[v]++; sp->npoints[v]++; } for (i = 0; i < sp->corners; i++) { if (MI_NPIXELS(mi) > 2) XSetForeground(display, gc, MI_PIXEL(mi, sp->colors[i])); XDrawPoints(display, MI_WINDOW(mi), gc, sp->pointBuffer[i], sp->npoints[i], CoordModeOrigin); sp->npoints[i] = 0; } if (++sp->time >= MI_CYCLES(mi)) startover(mi); }
static void drawCell_notused(ModeInfo * mi, int col, int row, unsigned char state) { circuitstruct *wp = &circuits[MI_SCREEN(mi)]; XGCValues gcv; GC gc; if (MI_NPIXELS(mi) > 2) { gc = MI_GC(mi); XSetForeground(MI_DISPLAY(mi), gc, MI_PIXEL(mi, wp->colors[state])); } else { gcv.stipple = wp->pixmaps[state]; gcv.foreground = MI_WHITE_PIXEL(mi); gcv.background = MI_BLACK_PIXEL(mi); XChangeGC(MI_DISPLAY(mi), wp->stippledGC, GCStipple | GCForeground | GCBackground, &gcv); gc = wp->stippledGC; } XFillRectangle(MI_DISPLAY(mi), MI_WINDOW(mi), MI_GC(mi), wp->xb + wp->xs * col, wp->yb + wp->ys * row, wp->xs - (wp->xs > 3), wp->ys - (wp->ys > 3)); }
static void level2_strike(Lightning bolt, ModeInfo * mi) { Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); Storm *st = &Helga[MI_SCREEN(mi)]; GC gc = MI_GC(mi); int i; /* This was originally designed to be a little darker then the level1 strike. This was changed to get it to work on multiscreens and to add more color variety. I tried stippling but it did not look good. */ if (MI_NPIXELS(mi) > 2) XSetForeground(display, gc, MI_PIXEL(mi, st->color)); else XSetForeground(display, gc, MI_WHITE_PIXEL(mi)); XDrawLine(display, window, gc, bolt.end1.x - 2, bolt.end1.y, bolt.middle[0].x - 2, bolt.middle[0].y); draw_line(mi, bolt.middle, BOLT_VERTICIES, gc, -2); XDrawLine(display, window, gc, bolt.middle[BOLT_VERTICIES - 1].x - 2, bolt.middle[BOLT_VERTICIES - 1].y, bolt.end2.x - 2, bolt.end2.y); XDrawLine(display, window, gc, bolt.end1.x + 2, bolt.end1.y, bolt.middle[0].x + 2, bolt.middle[0].y); draw_line(mi, bolt.middle, BOLT_VERTICIES, gc, 2); XDrawLine(display, window, gc, bolt.middle[BOLT_VERTICIES - 1].x + 2, bolt.middle[BOLT_VERTICIES - 1].y, bolt.end2.x + 2, bolt.end2.y); for (i = 0; i < bolt.fork_number; i++) { draw_line(mi, bolt.branch[i].ForkVerticies, bolt.branch[i].num_used, gc, -2); draw_line(mi, bolt.branch[i].ForkVerticies, bolt.branch[i].num_used, gc, 2); } level1_strike(bolt, mi); }
static void free_toneclock(Display *display, toneclockstruct *tclock) { ModeInfo *mi = tclock->mi; if (MI_IS_INSTALL(mi) && MI_NPIXELS(mi) > 2) { MI_WHITE_PIXEL(mi) = tclock->whitepixel; MI_BLACK_PIXEL(mi) = tclock->blackpixel; #ifndef STANDALONE MI_FG_PIXEL(mi) = tclock->fg; MI_BG_PIXEL(mi) = tclock->bg; #endif if (tclock->colors != NULL) { if (tclock->ncolors && !tclock->no_colors) free_colors(display, tclock->cmap, tclock->colors, tclock->ncolors); free(tclock->colors); tclock->colors = (XColor *) NULL; } if (tclock->cmap != None) { XFreeColormap(display, tclock->cmap); tclock->cmap = None; } } if (tclock->gc != None) { XFreeGC(display, tclock->gc); tclock->gc = None; } free_hour(tclock); #ifndef NO_DBUF if (tclock->dbuf != None) { XFreePixmap(display, tclock->dbuf); tclock->dbuf = None; } if (tclock->dbuf_gc != None) { XFreeGC(display, tclock->dbuf_gc); tclock->dbuf_gc = None; } #endif }
static void drawcell(ModeInfo * mi, int col, int row, unsigned int state) { Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); life1dstruct *lp = &life1ds[MI_SCREEN(mi)]; GC gc = lp->backGC; if (!state) { XSetForeground(display, gc, lp->black); XFillRectangle(display, window, gc, lp->xb + lp->xs * col, lp->yb + lp->ys * row, lp->xs, lp->ys); return; } if (MI_NPIXELS(mi) > 2) XSetForeground(display, gc, MI_PIXEL(mi, lp->colors[state - 1])); if (lp->pixelmode || (MI_NPIXELS(mi) <= 2)) { if (MI_NPIXELS(mi) <= 2) { XGCValues gcv; gcv.stipple = lp->pixmaps[state - 1]; gcv.foreground = MI_WHITE_PIXEL(mi); gcv.background = lp->black; gcv.fill_style = FillOpaqueStippled; XChangeGC(display, lp->stippledGC, GCStipple | GCFillStyle | GCForeground | GCBackground, &gcv); XFillRectangle(display, window, lp->stippledGC, lp->xb + lp->xs * col, lp->yb + lp->ys * row, lp->xs, lp->ys); } else XFillRectangle(display, window, gc, lp->xb + lp->xs * col, lp->yb + lp->ys * row, lp->xs, lp->ys); } else { (void) XPutImage(display, window, gc, lp->logo, 0, 0, lp->xb + lp->xs * col, lp->yb + lp->ys * row, lp->logo->width, lp->logo->height); } }
static void free_swirl(Display *display, swirlstruct *sp) { ModeInfo *mi = sp->mi; if (MI_IS_INSTALL(mi) && MI_NPIXELS(mi) > 2) { MI_WHITE_PIXEL(mi) = sp->whitepixel; MI_BLACK_PIXEL(mi) = sp->blackpixel; #ifndef STANDALONE MI_FG_PIXEL(mi) = sp->fg; MI_BG_PIXEL(mi) = sp->bg; #endif if (sp->colors != NULL) { if (sp->ncolors && !sp->no_colors) free_colors(display, sp->cmap, sp->colors, sp->ncolors); free(sp->colors); sp->colors = (XColor *) NULL; } if (sp->cmap != None) { XFreeColormap(display, sp->cmap); sp->cmap = None; } } if (sp->gc != None) { XFreeGC(display, sp->gc); sp->gc = None; } if (sp->ximage != None) { (void) XDestroyImage(sp->ximage); sp->ximage = None; } if (sp->knots != NULL) { free(sp->knots); sp->knots = (KNOT_P) NULL; } }
static void init_fly(ModeInfo * mi, Fly * f) { EyeScrInfo *ep = &eye_info[MI_SCREEN(mi)]; int win_width = MI_WIDTH(mi); int win_height = MI_HEIGHT(mi); (void) memset((char *) f, 0, sizeof (Fly)); /* clear everything to zero */ f->side = FLY_SIDE_LEFT; if (!MI_IS_ICONIC(mi)) { f->width = ep->flywidth; f->height = ep->flyheight; f->vx = NRAND(15) + 1; /* random horiz velocity */ } else { /* image is just a dot when iconic */ f->width = f->height = FLY_ICON_SIZE; f->vx = NRAND(4) + 1; /* slower when iconic */ } f->y = NRAND(win_height); if (f->y > (win_height / 2)) { f->side = FLY_SIDE_RIGHT; /* change to right side */ f->y -= win_height / 2; /* start in top half */ f->x = win_width - f->width; /* move to right of screen */ f->vx = -(f->vx); /* flip direction */ } f->oldx = -(f->width); /* prevent undraw 1st time */ if (MI_NPIXELS(mi) <= 2) { f->pixel = MI_WHITE_PIXEL(mi); /* always white when mono */ } else { f->pixel = MI_PIXEL(mi, NRAND(MI_NPIXELS(mi))); } }
ENTRYPOINT void init_grav(ModeInfo * mi) { unsigned char ball; gravstruct *gp; MI_INIT (mi, gravs); gp = &gravs[MI_SCREEN(mi)]; gp->width = MI_WIDTH(mi); gp->height = MI_HEIGHT(mi); gp->sr = STARRADIUS; gp->nplanets = MI_COUNT(mi); if (gp->nplanets < 0) { if (gp->planets) { (void) free((void *) gp->planets); gp->planets = (planetstruct *) NULL; } gp->nplanets = NRAND(-gp->nplanets) + 1; /* Add 1 so its not too boring */ } if (gp->planets == NULL) { if ((gp->planets = (planetstruct *) calloc(gp->nplanets, sizeof (planetstruct))) == NULL) return; } MI_CLEARWINDOW(mi); if (MI_NPIXELS(mi) > 2) gp->starcolor = MI_PIXEL(mi, NRAND(MI_NPIXELS(mi))); else gp->starcolor = MI_WHITE_PIXEL(mi); for (ball = 0; ball < (unsigned char) gp->nplanets; ball++) init_planet(mi, &gp->planets[ball]); }