コード例 #1
0
ファイル: vandeWiel.c プロジェクト: rforge/coin
void makeW(celW **W, int a, int b, int start, double *rs, double tol) {


    /*

    makeW simply determines whether a new polynomial W[i][j]
    can be found from mirrorW (if W[j-i][j] is available) or needs
    to be constructed via multiplication etc.

    */

    long i,j;
    int rank;
    int hulp;

    for (j = 1; j <= b; j++) {  /* verander naar 0!! */

        if (j < a) {
            hulp = j;
        } else {
            hulp = a;
        }

        for (i=1; i <= hulp; i++) {
            if (i <= j/2 || j == 1) {
                rank = start+j;
                fillcell(W, i, j, rank - 1, rs, tol);
            } else {
                mirrorW(W, i, j, start, rs);
            }
            R_CheckUserInterrupt();
        }
    }
}
コード例 #2
0
ファイル: ant.c プロジェクト: Bluerise/bitrig-xenocara
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);
}
コード例 #3
0
ファイル: wire.c プロジェクト: Gelma/xlockmore-for-13.04
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);
}
コード例 #4
0
ファイル: ant.c プロジェクト: Bluerise/bitrig-xenocara
static void
draw_anant(ModeInfo * mi, int direction, int col, int row)
{
	antfarmstruct *ap = &antfarms[MI_SCREEN(mi)];
	Display    *display = MI_DISPLAY(mi);
	Window      window = MI_WINDOW(mi);

	XSetForeground(display, MI_GC(mi), MI_WHITE_PIXEL(mi));
	fillcell(mi, MI_GC(mi), col, row);
	if (ap->eyes) {		/* Draw Eyes */
		XSetForeground(display, MI_GC(mi), MI_BLACK_PIXEL(mi));
		if (ap->neighbors == 6) {
			int         ccol = 2 * col + !(row & 1), crow = 2 * row;
			int         side, ang;
			XPoint      hex;

			if (!(ap->xs > 3 && ap->ys > 3))
				return;
			hex.x = ap->xb + ccol * ap->xs;
			hex.y = ap->yb + crow * ap->ys + ap->ys / 2;
			ang = direction * ap->neighbors / ANGLES;
			for (side = 0; side < ap->neighbors; side++) {
				if (side) {
					hex.x -= ap->shape.hexagon[side].x / 2;
					hex.y += ap->shape.hexagon[side].y / 2;
				}
				if (side == (ap->neighbors + ang - 2) % ap->neighbors)
					XDrawPoint(display, window, MI_GC(mi), hex.x, hex.y);
				if (side == (ap->neighbors + ang - 1) % ap->neighbors)
					XDrawPoint(display, window, MI_GC(mi), hex.x, hex.y);
			}
		} else if (ap->neighbors == 4 || ap->neighbors == 8) {
			if (!(ap->xs > 3 && ap->ys > 3))
				return;
			switch (direction) {
				case 0:
					XDrawPoint(display, window, MI_GC(mi),
						ap->xb + ap->xs * (col + 1) - 3,
					 	ap->yb + ap->ys * row + ap->ys / 2 - 2);
					XDrawPoint(display, window, MI_GC(mi),
						ap->xb + ap->xs * (col + 1) - 3,
					 	ap->yb + ap->ys * row + ap->ys / 2);
					break;
				case 45:
					XDrawPoint(display, window, MI_GC(mi),
					 	ap->xb + ap->xs * (col + 1) - 4,
						ap->yb + ap->ys * row + 1);
					XDrawPoint(display, window, MI_GC(mi),
					 	ap->xb + ap->xs * (col + 1) - 3,
						ap->yb + ap->ys * row + 2);
					break;
				case 90:
					XDrawPoint(display, window, MI_GC(mi),
					 	ap->xb + ap->xs * col + ap->xs / 2 - 2,
						ap->yb + ap->ys * row + 1);
					XDrawPoint(display, window, MI_GC(mi),
					 	ap->xb + ap->xs * col + ap->xs / 2,
						ap->yb + ap->ys * row + 1);
					break;
				case 135:
					XDrawPoint(display, window, MI_GC(mi),
					 	ap->xb + ap->xs * col + 2,
						ap->yb + ap->ys * row + 1);
					XDrawPoint(display, window, MI_GC(mi),
					 	ap->xb + ap->xs * col + 1,
						ap->yb + ap->ys * row + 2);
					break;
				case 180:
					XDrawPoint(display, window, MI_GC(mi),
						ap->xb + ap->xs * col + 1,
					 	ap->yb + ap->ys * row + ap->ys / 2 - 2);
					XDrawPoint(display, window, MI_GC(mi),
						ap->xb + ap->xs * col + 1,
					 	ap->yb + ap->ys * row + ap->ys / 2);
					break;
				case 225:
					XDrawPoint(display, window, MI_GC(mi),
					 	ap->xb + ap->xs * col + 2,
						ap->yb + ap->ys * (row + 1) - 3);
					XDrawPoint(display, window, MI_GC(mi),
					 	ap->xb + ap->xs * col + 1,
						ap->yb + ap->ys * (row + 1) - 4);
					break;
				case 270:
					XDrawPoint(display, window, MI_GC(mi),
					 	ap->xb + ap->xs * col + ap->xs / 2 - 2,
						ap->yb + ap->ys * (row + 1) - 3);
					XDrawPoint(display, window, MI_GC(mi),
					 	ap->xb + ap->xs * col + ap->xs / 2,
						ap->yb + ap->ys * (row + 1) - 3);
					break;
				case 315:
					XDrawPoint(display, window, MI_GC(mi),
					 	ap->xb + ap->xs * (col + 1) - 4,
						ap->yb + ap->ys * (row + 1) - 3);
					XDrawPoint(display, window, MI_GC(mi),
					 	ap->xb + ap->xs * (col + 1) - 3,
						ap->yb + ap->ys * (row + 1) - 4);
					break;
				default:
					(void) fprintf(stderr, "wrong eyes direction %d for ant eyes\n", direction);
			}
		} else {		/* TRI */
			int         orient = (col + row) % 2;	/* O left 1 right */
			int         side, ang;
			XPoint      tri;

			if (!(ap->xs > 6 && ap->ys > 6))
				return;
			tri.x = ap->xb + col * ap->xs;
			tri.y = ap->yb + row * ap->ys;
			if (orient)
				tri.x += (ap->xs / 6 - 1);
			else
				tri.x -= (ap->xs / 6 - 1);
			ang = direction * ap->neighbors / ANGLES;
			/* approx... does not work that well for even numbers */
			if (
#ifdef NUMBER_9
			ap->neighbors == 9 ||
#endif
			ap->neighbors == 12) {
#ifdef UNDER_CONSTRUCTION
				/* Not sure why this does not work */
				ang = ((ang + ap->neighbors / 6) / (ap->neighbors / 3)) % 3;
#else
				return;
#endif
			}
			for (side = 0; side < 3; side++) {
				if (side) {
					tri.x += ap->shape.triangle[orient][side].x / 3;
					tri.y += ap->shape.triangle[orient][side].y / 3;
				}
				/* Either you have the eyes in back or one eye in front */
#if 0
				if (side == ang)
					XDrawPoint(display, window, MI_GC(mi), tri.x, tri.y);
#else
				if (side == (ang + 2) % 3)
					XDrawPoint(display, window, MI_GC(mi), tri.x, tri.y);
				if (side == (ang + 1) % 3)
					XDrawPoint(display, window, MI_GC(mi), tri.x, tri.y);
#endif
			}
		}
	}
}