本文整理汇总了C++中MI_NPIXELS函数的典型用法代码示例。如果您正苦于以下问题:C++ MI_NPIXELS函数的具体用法?C++ MI_NPIXELS怎么用?C++ MI_NPIXELS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MI_NPIXELS函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: advanceColors
static void
advanceColors(ModeInfo * mi, int col, int row)
{
voterstruct *vp = &voters[MI_SCREEN(mi)];
CellList *curr;
curr = vp->first->next;
while (curr != vp->last) {
if (curr->info.col == col && curr->info.row == row) {
curr = curr->next;
removefrom_list(curr->previous);
} else {
if (curr->info.age > 0)
curr->info.age--;
else if (curr->info.age < 0)
curr->info.age++;
drawcell(mi, curr->info.col, curr->info.row,
(MI_NPIXELS(mi) + curr->info.age / FACTOR +
(MI_NPIXELS(mi) * curr->info.kind / BITMAPS)) % MI_NPIXELS(mi),
curr->info.kind, False);
if (curr->info.age == 0) {
curr = curr->next;
removefrom_list(curr->previous);
} else
curr = curr->next;
}
}
}
示例2: init_planet
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);
}
示例3: drawlissie
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;
}
}
}
}
示例4: init_planet
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);
}
示例5: draw_turtle
void
draw_turtle(ModeInfo * mi)
{
turtlestruct *tp;
if (turtles == NULL)
return;
tp = &turtles[MI_SCREEN(mi)];
if (++tp->time > MI_CYCLES(mi))
init_turtle(mi);
MI_IS_DRAWN(mi) = True;
if (MI_NPIXELS(mi) > 2)
XSetForeground(MI_DISPLAY(mi), MI_GC(mi),
MI_PIXEL(mi, NRAND(MI_NPIXELS(mi))));
tp->r = tp->r >> 1;
tp->level++;
if (tp->r > 1)
switch (tp->curve) {
case HILBERT:
switch (tp->dir) {
case 0:
tp->pt1.x = tp->pt2.x = tp->start.x + tp->r / 2;
tp->pt1.y = tp->pt2.y = tp->start.y + tp->r / 2;
generate_hilbert(mi, 0, tp->r);
break;
case 1:
tp->pt1.x = tp->pt2.x = tp->start.x + tp->min - tp->r / 2;
tp->pt1.y = tp->pt2.y = tp->start.y + tp->min - tp->r / 2;
generate_hilbert(mi, 0, -tp->r);
break;
case 2:
tp->pt1.x = tp->pt2.x = tp->start.x + tp->min - tp->r / 2;
tp->pt1.y = tp->pt2.y = tp->start.y + tp->min - tp->r / 2;
generate_hilbert(mi, -tp->r, 0);
break;
case 3:
tp->pt1.x = tp->pt2.x = tp->start.x + tp->r / 2;
tp->pt1.y = tp->pt2.y = tp->start.y + tp->r / 2;
generate_hilbert(mi, tp->r, 0);
}
break;
case CESARO_VAR:
generate_cesarovar(mi,
(double) tp->pt1.x, (double) tp->pt1.y,
(double) tp->pt2.x, (double) tp->pt2.y,
tp->level, tp->sign);
break;
case HARTER_HEIGHTWAY:
generate_harter_heightway(mi,
(double) tp->pt1.x, (double) tp->pt1.y,
(double) tp->pt2.x, (double) tp->pt2.y,
tp->level, tp->sign);
break;
}
}
示例6: draw_blot
void
draw_blot(ModeInfo * mi)
{
blotstruct *bp;
XPoint *xp;
int x, y, k;
if (blots == NULL)
return;
bp = &blots[MI_SCREEN(mi)];
xp = bp->pointBuffer;
if (xp == NULL)
init_blot(mi);
MI_IS_DRAWN(mi) = True;
if (MI_NPIXELS(mi) > 2) {
XSetForeground(MI_DISPLAY(mi), MI_GC(mi), MI_PIXEL(mi, bp->pix));
if (++bp->pix >= MI_NPIXELS(mi))
bp->pix = 0;
}
x = bp->xmid;
y = bp->ymid;
k = bp->size;
while (k >= 4) {
x += (NRAND(1 + (bp->offset << 1)) - bp->offset);
y += (NRAND(1 + (bp->offset << 1)) - bp->offset);
k--;
xp->x = x;
xp->y = y;
xp++;
if (bp->xsym) {
k--;
xp->x = bp->width - x;
xp->y = y;
xp++;
}
if (bp->ysym) {
k--;
xp->x = x;
xp->y = bp->height - y;
xp++;
}
if (bp->xsym && bp->ysym) {
k--;
xp->x = bp->width - x;
xp->y = bp->height - y;
xp++;
}
}
XDrawPoints(MI_DISPLAY(mi), MI_WINDOW(mi), MI_GC(mi),
bp->pointBuffer, (bp->size - k), CoordModeOrigin);
if (++bp->count > MI_CYCLES(mi))
init_blot(mi);
}
示例7: draw_fadeplot
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);
}
}
示例8: random_petal
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);
}
示例9: init_fadeplot
ENTRYPOINT void
init_fadeplot (ModeInfo * mi)
{
fadeplotstruct *fp;
if (fadeplots == NULL) {
if ((fadeplots = (fadeplotstruct *) calloc(MI_NUM_SCREENS(mi),
sizeof (fadeplotstruct))) == NULL)
return;
}
fp = &fadeplots[MI_SCREEN(mi)];
fp->width = MI_WIDTH(mi);
fp->height = MI_HEIGHT(mi);
fp->min = MAX(MIN(fp->width, fp->height) / 2, 1);
fp->speed.x = 8;
fp->speed.y = 10;
fp->step.x = 1;
fp->step.y = 1;
fp->temps = 0;
fp->factor.x = MAX(fp->width / (2 * fp->min), 1);
fp->factor.y = MAX(fp->height / (2 * fp->min), 1);
fp->nbstep = MI_COUNT(mi);
if (fp->nbstep < -MINSTEPS) {
fp->nbstep = NRAND(-fp->nbstep - MINSTEPS + 1) + MINSTEPS;
} else if (fp->nbstep < MINSTEPS)
fp->nbstep = MINSTEPS;
fp->maxpts = MI_CYCLES(mi);
if (fp->maxpts < 1)
fp->maxpts = 1;
if (fp->pts == NULL) {
if ((fp->pts = (XPoint *) calloc(fp->maxpts, sizeof (XPoint))) ==
NULL) {
free_fadeplot(fp);
return;
}
}
if (MI_NPIXELS(mi) > 2)
fp->pix = NRAND(MI_NPIXELS(mi));
if (fp->stab != NULL)
(void) free((void *) fp->stab);
if (!initSintab(mi))
return;
MI_CLEARWINDOW(mi);
}
示例10: init_grav
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);
}
示例11: refresh_tik_tak
void
refresh_tik_tak(ModeInfo * mi)
{
Display *display = MI_DISPLAY(mi);
int i;
tik_takstruct *tiktak;
if (tik_taks == NULL)
return;
tiktak = &tik_taks[MI_SCREEN(mi)];
if (tiktak->object == NULL)
return;
if (!tiktak->painted)
return;
MI_CLEARWINDOW(mi);
XSetFunction(display, tiktak->gc, GXxor);
for (i = 0; i < tiktak->num_object; i++) {
tik_takobject *object0;
object0 = &tiktak->object[i];
if (MI_IS_INSTALL(mi) && MI_NPIXELS(mi) > 2) {
XSetForeground(display, tiktak->gc, tiktak->colors[object0->colour].pixel);
} else {
XSetForeground(display, tiktak->gc, object0->colour);
}
tik_tak_setupobject( mi , object0);
tik_tak_reset_object( object0);
tik_tak_drawobject(mi, object0 );
}
XSetFunction(display, tiktak->gc, GXcopy);
}
示例12: free_mandelbrot
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;
}
}
示例13: drawcell
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);
}
示例14: refresh_voters
void
refresh_voters(ModeInfo * mi)
{
int col, row, colrow;
voterstruct *vp;
if (voters == NULL)
return;
vp = &voters[MI_SCREEN(mi)];
if (vp->first == NULL)
return;
if (vp->painted) {
MI_CLEARWINDOW(mi);
vp->painted = False;
for (row = 0; row < vp->nrows; row++)
for (col = 0; col < vp->ncols; col++) {
colrow = col + row * vp->ncols;
/* Draw all old, will get corrected soon if wrong... */
drawcell(mi, col, row,
(unsigned long) (MI_NPIXELS(mi) * vp->arr[colrow] / BITMAPS),
vp->arr[colrow], False);
}
}
}
示例15: fixedColors
Bool
fixedColors(ModeInfo * mi)
{
Bool temp;
#ifdef FORCEFIXEDCOLORS
/* pretending a fixed colourmap */
return TRUE;
#else
/* get information about the default visual */
temp = (!((MI_NPIXELS(mi) > 2) &&
(MI_VISUALCLASS(mi) != StaticGray) &&
(MI_VISUALCLASS(mi) != StaticColor) &&
(MI_VISUALCLASS(mi) != TrueColor) &&
#if 0
/*-
* This may fix wrong colors (possibly unreadable text) in password window
*/
!MI_IS_ICONIC(mi) &&
#endif
!MI_IS_INROOT(mi) &&
MI_IS_INSTALL(mi)));
#endif
if (debug) {
(void) printf("%s colors on screen %d\n", (temp) ? "fixed" : "writeable",
MI_SCREEN(mi));
}
return temp;
}