Example #1
0
void
copyplane_test(void)
{
  int num_copies = 200;
  int i;
  long totaltime;
  char buf[80];

  if(!X.gcv.plane_mask || (X.gcv.plane_mask & (X.gcv.plane_mask - 1))) {
    show_result("exactly one bit in plane mask must be set for this test");
    return;
  }


  num_copies *= X.percent;

  XSetPlaneMask(X.dpy, X.gc, ~0L);
  XSetFillStyle(X.dpy,X.miscgc,FillTiled);
  XFillRectangle(X.dpy,X.win,X.miscgc,0,0,400,400);

  XSync(X.dpy,0);
  timer(StartTimer);
  for (i=0;i<num_copies;++i)
    XCopyPlane(X.dpy,X.win,X.win,X.gc,i,200-i,
	      200,200,200-i,i,X.gcv.plane_mask);
  XSync(X.dpy,0);
  totaltime = timer(EndTimer);
  XSetPlaneMask(X.dpy, X.gc, X.gcv.plane_mask);

  snprintf(buf,sizeof buf,"%.2f seconds.",(double)totaltime/1000000.);
  show_result(buf);
}
Example #2
0
static void Paint_world_radar_new(void)
{
    int i, j, xoff, yoff;
    ipos_t min, max;
    static XPoint poly[10000];
    
    /* what the heck is this? */
    radar_exposures = 2;

    if (radarPixmap2 == radarPixmap)
	XSetPlaneMask(dpy, radarGC, AllPlanes & (~(dpl_1[0] | dpl_1[1])));

    if (radarPixmap2 != radarWindow) {
	/* Clear radar */
	XSetForeground(dpy, radarGC, colors[BLACK].pixel);
	XFillRectangle(dpy, radarPixmap2, radarGC, 0, 0, 256, RadarHeight);
    } else
	XClearWindow(dpy, radarWindow);
        
    XSetForeground(dpy, radarGC, colors[wallRadarColor].pixel);
    
    /* loop through all the polygons */
    for (i = 0; i < num_polygons; i++) {
	if (BIT(polygon_styles[polygons[i].style].flags,
		STYLE_INVISIBLE_RADAR)) continue;
	Compute_radar_bounds(&min, &max, &polygons[i].bounds);
	for (xoff = min.x; xoff <= max.x; xoff++) {
	    for (yoff = min.y; yoff <= max.y; yoff++) {
		int x, y;

		x = xoff * Setup->width;
		y = yoff * Setup->height;
		
		/* loop through the points in the current polygon */
		for (j = 0; j < polygons[i].num_points; j++) {		    
		    x += polygons[i].points[j].x;
		    y += polygons[i].points[j].y;
		    poly[j].x = (x * 256) / Setup->width;
		    poly[j].y = (int)RadarHeight 
			- ((y * (int)RadarHeight) / Setup->height);
		}

		XSetForeground(dpy, radarGC, fullColor ?
			       polygon_styles[polygons[i].style].color :
			       colors[wallRadarColor].pixel);
		XFillPolygon(dpy, radarPixmap2, radarGC, poly,
			     polygons[i].num_points,
			     Nonconvex, CoordModeOrigin);
	    }
	}
    }
    
    if (radarPixmap2 == radarPixmap)
	XSetPlaneMask(dpy, radarGC, AllPlanes & (~(dpl_2[0] | dpl_2[1])));
}
void ui_sel_drawBoxes (struct Ui_DisplayType *displayPtr, FlagType scope,
		struct PosType gridPos)

{   
    struct PosType  pos1, pos2, pixOffset;
    struct Ui_DisplayType *dPtr;
    struct SelectionType  *selPtr;

    if (scope == UI_GLOBAL) {
	for (dPtr = ui_displ_listPtr;
	     dPtr != NULL;
	     dPtr = dPtr ->nextPtr) 
	    ui_sel_drawBoxes(dPtr, UI_LOCAL, gridPos);
    } else { /* UI_LOCAL */

	pixOffset.x = displayPtr->gridSize * gridPos.x;
	pixOffset.y = displayPtr->gridSize * gridPos.y;
	
	XSetFunction(ui_display, ui_gc, GXinvert);
	XSetBackground(ui_display, ui_gc, 
		       ui_backgroundColor);
	XSetForeground(ui_display, ui_gc, 
		       ui_textColor);
	
	if (ui_col_colorDisplay)
	    XSetPlaneMask(ui_display, ui_gc, 
			  ui_textColor 
			  BIT_XOR 
			  ui_backgroundColor);
	
	for (selPtr = ui_sel_listPtr;
	     selPtr != NULL;
	     selPtr = selPtr->nextPtr) {
	    
	    if ((NOT displayPtr->frozen) AND 
		(displayPtr->subNetNo == ui_currentDisplay->subNetNo)) {
		
		pos1    = ui_utilGridToPix(displayPtr, selPtr->gridPos);
		pos1.x -= ((ui_selectionSize+2) / 2) - pixOffset.x;
		pos1.y -= ((ui_selectionSize+2) / 2) - pixOffset.y;
		pos2.x  = pos1.x + ui_selectionSize+2 - 1;
		pos2.y  = pos1.y + ui_selectionSize+2 - 1;
		ui_xDrawBox(ui_display, displayPtr->drawable, ui_gc, 
			    pos1, pos2);
	    }
	}
    }

    if (ui_col_colorDisplay)
	XSetPlaneMask(ui_display, ui_gc, AllPlanes);
}
Example #4
0
void do_planes() {
	int over=0;
	int finished=0;
	int width, xloc, yloc, dist, size, i;
	short** heights;

	heights=(short **) malloc(DisplayPlanes(dpy, screen));
	for (i=0; i < DisplayPlanes(dpy, screen); i++) {
		heights[i]=(short *) calloc(sizeof(short),
			DisplayWidth(dpy, screen));
	}
	while (!over) {
		depth=rnd(DisplayPlanes(dpy, screen));
		width=rnd(MIN_WIDTH)+WIDTH_ADD;

		xloc=calc_xloc(width);

		yloc=DisplayHeight(dpy, screen);
		for (i=xloc; i < (xloc+width); i++) {
			yloc=min(yloc, heights[depth][i]);
		}
		if (yloc == DisplayHeight(dpy, screen))
			continue;
		dist=rnd(yloc/10+MIN_DIST);
		size=rnd(max(yloc+MIN_SIZE, MAX_SIZE));

		XSetPlaneMask(dpy, copygc, 1<<depth);
		XSetPlaneMask(dpy, fillgc, 1<<depth);
		XCopyArea(dpy, win, win, copygc,
			xloc, yloc,
			width, size,
			xloc, yloc+dist);
		XFillRectangle(dpy, win, fillgc,
			xloc, yloc,
			width, dist);
		yloc+=dist;
		for (i=xloc; i < (xloc+width); i++) {
			if ((heights[depth][i] < (DisplayHeight(dpy, screen)-MIN_SIZE)) && (yloc >= (DisplayHeight(dpy, screen)-MIN_SIZE)))
				finished++;
			heights[depth][i]=max(heights[depth][i], yloc);
		}
		if (finished >= (DisplayWidth(dpy, screen)-FINISHED)) {
			XSync(dpy, 0);
			over=1;
		}
	}
}
Example #5
0
/*
 * Try and draw an area of the radar which represents block position
 * 'xi' 'yi'.  If 'draw' is zero the area is cleared.
 */
static void Paint_radar_block(int xi, int yi, int color)
{
    double	xs, ys;
    int		xp, yp, xw, yw;

    if (radarPixmap2 == radarPixmap) {
	XSetPlaneMask(dpy, radarGC, AllPlanes & ~(dpl_1[0] | dpl_1[1]));
    }
    XSetForeground(dpy, radarGC, colors[color].pixel);

    if (Setup->x >= 256) {
	xs = (double)(256 - 1) / (Setup->x - 1);
	ys = (double)(RadarHeight - 1) / (Setup->y - 1);
	xp = (int)(xi * xs + 0.5);
	yp = RadarHeight - 1 - (int)(yi * ys + 0.5);
	XDrawPoint(dpy, radarPixmap2, radarGC, xp, yp);
    } else {
	xs = (double)(Setup->x - 1) / (256 - 1);
	ys = (double)(Setup->y - 1) / (RadarHeight - 1);
	/*
	 * Calculate the min and max points on the radar that would show
	 * block position 'xi' and 'yi'.  Note 'xp' is the minimum x coord
	 * for 'xi',which is one more than the previous xi value would give,
	 * and 'xw' is the maximum, which is then changed to a width value.
	 * Similarly for 'yw' and 'yp' (the roles are reversed because the
	 * radar is upside down).
	 */
	xp = (int)((xi - 0.5) / xs) + 1;
	xw = (int)((xi + 0.5) / xs);
	yw = (int)((yi - 0.5) / ys) + 1;
	yp = (int)((yi + 0.5) / ys);
	xw -= xp;
	yw = yp - yw;
	yp = RadarHeight - 1 - yp;
	XFillRectangle(dpy, radarPixmap2, radarGC, xp, yp,
		       (unsigned)xw+1, (unsigned)yw+1);
    }
    if (radarPixmap2 == radarPixmap)
	XSetPlaneMask(dpy, radarGC,
		      AllPlanes & ~(dpl_2[0] | dpl_2[1]));
}
Example #6
0
void SetColor(int color)
{
  if (cur_di == NULL || display == NULL)
    return;

  cur_di->foreground = color;

  if (cur_di->mask != 0xffffffff)
    XSetPlaneMask(display, drawgc, cur_di->foreground ^ cur_di->background);
  else
    XSetForeground(display, drawgc, color);
}
Example #7
0
void SetDrawMode(int mode)
{
  if (display == NULL)
    return;

  if (mode == SANE_XOR)
   {
     cur_di->mask = cur_di->foreground ^ cur_di->background;
     XSetForeground(display, drawgc, 0xffffffff);
     XSetBackground(display, drawgc, cur_di->background);
     XSetFunction(display,   drawgc, GXxor);
     XSetPlaneMask(display,  drawgc, cur_di->mask);
   }
  else
   {
     XSetForeground(display, drawgc, cur_di->foreground);
     XSetBackground(display, drawgc, cur_di->background);
     XSetFunction(display,   drawgc, mode);
     XSetPlaneMask(display,  drawgc, 0xffffffff);
     cur_di->mask = 0xffffffff;
   }
}
Example #8
0
static PyObject *
PaxGC_SetPlaneMask(PaxGCObject *self, PyObject*args)
{
	unsigned long arg1;
	if (self->shared) {
		PyErr_SetString(PyExc_TypeError, "can't modify shared GC");
		return NULL;
	}
	if (!PyArg_ParseTuple(args, "l",
			&arg1))
		return NULL;
XSetPlaneMask(self->display, self->gc,
			arg1);
	Py_INCREF(Py_None);
	return Py_None;
}
Example #9
0
/*
 * The following function initializes a toplevel window.
 * It returns 0 if the initialization was successful,
 * or -1 if it couldn't initialize the double buffering routine.
 */
int Init_top(void)
{
    int					top_x, top_y;
    int					i;
    int					x, y;
    unsigned				w, h;
    unsigned long			values;
    int					top_flags;
    XGCValues				xgc;
    XSetWindowAttributes		sattr;
    unsigned long			mask;

    if (topWindow)
	fatal("Init_top called twice");

    if (Colors_init() == -1)
	return -1;

    radarDrawRectanglePtr = XFillRectangle;

    /*
     * Get toplevel geometry.
     */
    top_flags = 0;
    if (geometry != NULL && geometry[0] != '\0')
	mask = XParseGeometry(geometry, &x, &y, &w, &h);
    else
	mask = 0;

    if ((mask & WidthValue) != 0) {
	top_width = w;
	top_flags |= USSize;
    } else {
	top_width = DEF_TOP_WIDTH;
	top_flags |= PSize;
    }
    LIMIT(top_width, MIN_TOP_WIDTH, MAX_TOP_WIDTH);
    if ((mask & HeightValue) != 0) {
	top_height = h;
	top_flags |= USSize;
    } else {
	top_height = DEF_TOP_HEIGHT;
	top_flags |= PSize;
    }
    LIMIT(top_height, MIN_TOP_HEIGHT, MAX_TOP_HEIGHT);
    if ((mask & XValue) != 0) {
	if ((mask & XNegative) != 0)
	    top_x = DisplayWidth(dpy, DefaultScreen(dpy)) - top_width + x;
	else
	    top_x = x;
	top_flags |= USPosition;
    } else {
	top_x = (DisplayWidth(dpy, DefaultScreen(dpy)) - top_width) /2;
	top_flags |= PPosition;
    }
    if ((mask & YValue) != 0) {
	if ((mask & YNegative) != 0)
	    top_y = DisplayHeight(dpy, DefaultScreen(dpy)) - top_height + y;
	else
	    top_y = y;
	top_flags |= USPosition;
    } else {
	top_y = (DisplayHeight(dpy, DefaultScreen(dpy)) - top_height) /2;
	top_flags |= PPosition;
    }
    if (geometry != NULL) {
	free(geometry);
	geometry = NULL;
    }

    /*
     * Create toplevel window (we need this first so that we can create GCs)
     */
    mask = 0;
    /*old debug: sattr.background_pixel = colors[WHITE].pixel;*/
    sattr.background_pixel = colors[BLACK].pixel;
    mask |= CWBackPixel;
    sattr.border_pixel = colors[WHITE].pixel;
    mask |= CWBorderPixel;
    if (colormap != 0) {
	sattr.colormap = colormap;
	mask |= CWColormap;
    }
    if (ignoreWindowManager) {
	sattr.override_redirect = True;
	mask |= CWOverrideRedirect;
    }
    topWindow = XCreateWindow(dpy,
			      DefaultRootWindow(dpy),
			      top_x, top_y,
			      top_width, top_height,
			      0, (int)dispDepth,
			      InputOutput, visual,
			      mask, &sattr);
    XSelectInput(dpy, topWindow,
		 KeyPressMask | KeyReleaseMask
		 | FocusChangeMask | StructureNotifyMask);
    Init_disp_prop(dpy, topWindow, top_width, top_height,
		   top_x, top_y, top_flags);
    if (kdpy) {
	int scr = DefaultScreen(kdpy);
	keyboardWindow = XCreateSimpleWindow(kdpy,
					     DefaultRootWindow(kdpy),
					     top_x, top_y,
					     top_width, top_height,
					     0, 0, BlackPixel(dpy, scr));
	XSelectInput(kdpy, keyboardWindow,
		     KeyPressMask | KeyReleaseMask | FocusChangeMask);
	Init_disp_prop(kdpy, keyboardWindow, top_width, top_height,
		       top_x, top_y, top_flags);
    }

    /*
     * Create item bitmaps
     */
    for (i = 0; i < NUM_ITEMS; i++)
	itemBitmaps[i]
	    = XCreateBitmapFromData(dpy, topWindow,
				    (char *)itemBitmapData[i].data,
				    ITEM_SIZE, ITEM_SIZE);

    /*
     * Creates and initializes the graphic contexts.
     */
    xgc.line_width = 0;
    xgc.line_style = LineSolid;
    xgc.cap_style = CapButt;
    xgc.join_style = JoinMiter;		/* I think this is fastest, is it? */
    xgc.graphics_exposures = False;
    values
	= GCLineWidth|GCLineStyle|GCCapStyle|GCJoinStyle|GCGraphicsExposures;

    messageGC	= XCreateGC(dpy, topWindow, values, &xgc);
    radarGC	= XCreateGC(dpy, topWindow, values, &xgc);
    buttonGC	= XCreateGC(dpy, topWindow, values, &xgc);
    scoreListGC	= XCreateGC(dpy, topWindow, values, &xgc);
    textGC	= XCreateGC(dpy, topWindow, values, &xgc);
    talkGC	= XCreateGC(dpy, topWindow, values, &xgc);
    motdGC	= XCreateGC(dpy, topWindow, values, &xgc);
    gameGC	= XCreateGC(dpy, topWindow, values, &xgc);
    XSetBackground(dpy, gameGC, colors[BLACK].pixel);

    /*
     * Set fonts
     */
    gameFont
	= Set_font(dpy, gameGC, gameFontName, "gameFont");
    messageFont
	= Set_font(dpy, messageGC, messageFontName, "messageFont");
    scoreListFont
	= Set_font(dpy, scoreListGC, scoreListFontName, "scoreListFont");
    buttonFont
	= Set_font(dpy, buttonGC, buttonFontName, "buttonFont");
    textFont
	= Set_font(dpy, textGC, textFontName, "textFont");
    talkFont
	= Set_font(dpy, talkGC, talkFontName, "talkFont");
    motdFont
	= Set_font(dpy, motdGC, motdFontName, "motdFont");

    XSetState(dpy, gameGC,
	      WhitePixel(dpy, DefaultScreen(dpy)),
	      BlackPixel(dpy, DefaultScreen(dpy)),
	      GXcopy, AllPlanes);
    XSetState(dpy, radarGC,
	      WhitePixel(dpy, DefaultScreen(dpy)),
	      BlackPixel(dpy, DefaultScreen(dpy)),
	      GXcopy, AllPlanes);
    XSetState(dpy, messageGC,
	      WhitePixel(dpy, DefaultScreen(dpy)),
	      BlackPixel(dpy, DefaultScreen(dpy)),
	      GXcopy, AllPlanes);
    XSetState(dpy, buttonGC,
	      WhitePixel(dpy, DefaultScreen(dpy)),
	      BlackPixel(dpy, DefaultScreen(dpy)),
	      GXcopy, AllPlanes);
    XSetState(dpy, scoreListGC,
	      WhitePixel(dpy, DefaultScreen(dpy)),
	      BlackPixel(dpy, DefaultScreen(dpy)),
	      GXcopy, AllPlanes);

    if (dbuf_state->type == COLOR_SWITCH)
	XSetPlaneMask(dpy, gameGC, dbuf_state->drawing_planes);

    return 0;
}
Example #10
0
static void Paint_world_radar_old(void)
{
    int			i, xi, yi, xm, ym, xp, yp = 0;
    int			xmoff, xioff;
    int			type, vis;
    double		damage;
    double		xs, ys;
    int			npoint = 0, nsegment = 0;
    int			start, end;
    int			currColor, visibleColorChange;
    const int		max = 256;
    u_byte		visible[256];
    u_byte		visibleColor[256];
    XSegment		segments[256];
    XPoint		points[256];

    radar_exposures = 2;

    if (radarPixmap2 == radarPixmap)
	XSetPlaneMask(dpy, radarGC,
		      AllPlanes & ~(dpl_1[0] | dpl_1[1]));

    if (radarPixmap2 != radarWindow) {
	/* Clear radar */
	XSetForeground(dpy, radarGC, colors[BLACK].pixel);
	XFillRectangle(dpy, radarPixmap2, radarGC, 0, 0, 256, RadarHeight);
    } else
	XClearWindow(dpy, radarWindow);

    /*
     * Calculate an array which is later going to be indexed
     * by map block type.  The indexing should return a true
     * value when the map block should be visible on the radar
     * and a false value otherwise.
     */
    memset(visible, 0, sizeof visible);
    visible[SETUP_FILLED] = 1;
    visible[SETUP_FILLED_NO_DRAW] = 1;
    visible[SETUP_REC_LU] = 1;
    visible[SETUP_REC_RU] = 1;
    visible[SETUP_REC_LD] = 1;
    visible[SETUP_REC_RD] = 1;
    visible[SETUP_FUEL] = 1;
    for (i = 0; i < 10; i++)
	visible[SETUP_TARGET+i] = 1;

    for (i = BLUE_BIT; i < (int)sizeof visible; i++)
	visible[i] = 1;

    if (instruments.showDecor) {
	visible[SETUP_DECOR_FILLED] = 1;
	visible[SETUP_DECOR_LU] = 1;
	visible[SETUP_DECOR_RU] = 1;
	visible[SETUP_DECOR_LD] = 1;
	visible[SETUP_DECOR_RD] = 1;
    }

    /*
     * Calculate an array which returns the color to use
     * for drawing when indexed with a map block type.
     */
    memset(visibleColor, 0, sizeof visibleColor);
    visibleColor[SETUP_FILLED] =
	visibleColor[SETUP_FILLED_NO_DRAW] =
	visibleColor[SETUP_REC_LU] =
	visibleColor[SETUP_REC_RU] =
	visibleColor[SETUP_REC_LD] =
	visibleColor[SETUP_REC_RD] =
	visibleColor[SETUP_FUEL] = wallRadarColor;
    for (i = 0; i < 10; i++)
	visibleColor[SETUP_TARGET+i] = targetRadarColor;

    for (i = BLUE_BIT; i < (int)sizeof visible; i++)
	visibleColor[i] = wallRadarColor;

    if (instruments.showDecor)
	visibleColor[SETUP_DECOR_FILLED] =
	    visibleColor[SETUP_DECOR_LU] =
	    visibleColor[SETUP_DECOR_RU] =
	    visibleColor[SETUP_DECOR_LD] =
	    visibleColor[SETUP_DECOR_RD] = decorRadarColor;

    /* The following code draws the map on the radar.  Segments and
     * points arrays are use to build lists of things to be drawn.
     * Normally the segments and points are drawn when the arrays are
     * full, but now they are also drawn when the color changes.  The
     * visibleColor array is used to determine the color to be used
     * for the given visible block type.
     *
     * Another (and probably better) way to do this would be use
     * different segments and points arrays for each visible color.
     */
    if (Setup->x >= 256) {
	xs = (double)(256 - 1) / (Setup->x - 1);
	ys = (double)(RadarHeight - 1) / (Setup->y - 1);
	currColor = -1;
	for (xi = 0; xi < Setup->x; xi++) {
	    start = end = -1;
	    xp = (int)(xi * xs + 0.5);
	    xioff = xi * Setup->y;
	    for (yi = 0; yi < Setup->y; yi++) {
		visibleColorChange = 0;
		type = Setup->map_data[xioff + yi];
		if (type >= SETUP_TARGET && type < SETUP_TARGET + 10)
		    vis = (Target_alive(xi, yi, &damage) == 0);
		else
		    vis = visible[type];

		if (vis) {
		    yp = (int)(yi * ys + 0.5);
		    if (start == -1) {
			if ((nsegment > 0 || npoint > 0)
			    && currColor != visibleColor[type]) {
			    if (nsegment > 0) {
				XDrawSegments(dpy, radarPixmap2, radarGC,
					      segments, nsegment);
				nsegment = 0;
			    }
			    if (npoint > 0) {
				XDrawPoints(dpy, radarPixmap2, radarGC,
					    points, npoint, CoordModeOrigin);
				npoint = 0;
			    }
			}
			start = end = yp;
			currColor = visibleColor[type];
			XSetForeground(dpy, radarGC, colors[currColor].pixel);
		    } else {
			end = yp;
			visibleColorChange = (visibleColor[type] != currColor);
		    }
		}

		if (start != -1
		    && (!vis || yi == Setup->y - 1 || visibleColorChange)) {
		    if (end > start) {
			segments[nsegment].x1 = xp;
			segments[nsegment].y1 = RadarHeight - 1 - start;
			segments[nsegment].x2 = xp;
			segments[nsegment].y2 = RadarHeight - 1 - end;
			nsegment++;
			if (nsegment >= max || yi == Setup->y - 1) {
			    XDrawSegments(dpy, radarPixmap2, radarGC,
					  segments, nsegment);
			    nsegment = 0;
			}
		    } else {
			points[npoint].x = xp;
			points[npoint].y = RadarHeight - 1 - start;
			npoint++;
			if (npoint >= max || yi == Setup->y - 1) {
			    XDrawPoints(dpy, radarPixmap2, radarGC,
					points, npoint, CoordModeOrigin);
			    npoint = 0;
			}
		    }
		    start = end = -1;
		}

		if (visibleColorChange) {
		    if (nsegment > 0) {
			XDrawSegments(dpy, radarPixmap2, radarGC,
				      segments, nsegment);
			nsegment = 0;
		    }
		    if (npoint > 0) {
			XDrawPoints(dpy, radarPixmap2, radarGC,
				    points, npoint, CoordModeOrigin);
			npoint = 0;
		    }
		    start = end = yp;
		    currColor = visibleColor[type];
		    XSetForeground(dpy, radarGC, colors[currColor].pixel);
		}
	    }
	}
    } else {
	xs = (double)(Setup->x - 1) / (256 - 1);
	ys = (double)(Setup->y - 1) / (RadarHeight - 1);
	currColor = -1;
	for (xi = 0; xi < 256; xi++) {
	    xm = (int)(xi * xs + 0.5);
	    xmoff = xm * Setup->y;
	    start = end = -1;
	    xp = xi;
	    for (yi = 0; yi < (int)RadarHeight; yi++) {
		visibleColorChange = 0;
		ym = (int)(yi * ys + 0.5);
		type = Setup->map_data[xmoff + ym];
		vis = visible[type];
		if (type >= SETUP_TARGET && type < SETUP_TARGET + 10)
		    vis = (Target_alive(xm, ym, &damage) == 0);
		if (vis) {
		    yp = yi;
		    if (start == -1) {
			if ((nsegment > 0 || npoint > 0)
			    && currColor != visibleColor[type]) {
			    if (nsegment > 0) {
				XDrawSegments(dpy, radarPixmap2, radarGC,
					      segments, nsegment);
				nsegment = 0;
			    }
			    if (npoint > 0) {
				XDrawPoints(dpy, radarPixmap2, radarGC,
					    points, npoint, CoordModeOrigin);
				npoint = 0;
			    }
			}
			start = end = yp;
			currColor = visibleColor[type];
			XSetForeground(dpy, radarGC, colors[currColor].pixel);
		    } else {
			end = yp;
			visibleColorChange = visibleColor[type] != currColor;
		    }
		}

		if (start != -1
		    && (!vis || yi == (int)RadarHeight - 1
			|| visibleColorChange)) {
		    if (end > start) {
			segments[nsegment].x1 = xp;
			segments[nsegment].y1 = RadarHeight - 1 - start;
			segments[nsegment].x2 = xp;
			segments[nsegment].y2 = RadarHeight - 1 - end;
			nsegment++;
			if (nsegment >= max || yi == (int)RadarHeight - 1) {
			    XDrawSegments(dpy, radarPixmap2, radarGC,
					  segments, nsegment);
			    nsegment = 0;
			}
		    } else {
			points[npoint].x = xp;
			points[npoint].y = RadarHeight - 1 - start;
			npoint++;
			if (npoint >= max || yi == (int)RadarHeight - 1) {
			    XDrawPoints(dpy, radarPixmap2, radarGC,
					points, npoint, CoordModeOrigin);
			    npoint = 0;
			}
		    }
		    start = end = -1;
		}

		if (visibleColorChange) {
		    if (nsegment > 0) {
			XDrawSegments(dpy, radarPixmap2, radarGC,
				      segments, nsegment);
			nsegment = 0;
		    }
		    if (npoint > 0) {
			XDrawPoints(dpy, radarPixmap2, radarGC,
				    points, npoint, CoordModeOrigin);
			npoint = 0;
		    }
		    start = end = yp;
		    currColor = visibleColor[type];
		    XSetForeground(dpy, radarGC, colors[currColor].pixel);
		}
	    }
	}
    }
    if (nsegment > 0)
	XDrawSegments(dpy, radarPixmap2, radarGC, segments, nsegment);

    if (npoint > 0)
	XDrawPoints(dpy, radarPixmap2, radarGC,
		    points, npoint, CoordModeOrigin);

    if (radarPixmap2 == radarPixmap)
	XSetPlaneMask(dpy, radarGC,
		      AllPlanes & ~(dpl_2[0] | dpl_2[1]));

    for (i = 0;; i++) {
	int dead_time;
	double targ_damage;

	if (Target_by_index(i, &xi, &yi, &dead_time, &targ_damage) == -1)
	    break;
	if (dead_time)
	    continue;
	Paint_radar_block(xi, yi, targetRadarColor);
    }
}
Example #11
0
void Painter::SetPlaneMask(int m) {
    XDisplay* dpy = rep->display->rep()->display_;
    XSetPlaneMask(dpy, rep->fillgc, m);
    XSetPlaneMask(dpy, rep->dashgc, m);
}
Example #12
0
void
draw_goop(ModeInfo * mi)
{
	Display    *display = MI_DISPLAY(mi);
	Window      window = MI_WINDOW(mi);
	int         i;
	goopstruct *gp;

	if (goops == NULL)
		return;
	gp = &goops[MI_SCREEN(mi)];
	if (gp->layers == NULL)
		return;

	MI_IS_DRAWN(mi) = True;
	switch (gp->mode) {
		case transparent:

			for (i = 0; i < gp->nlayers; i++)
				draw_layer_plane(display, &(gp->layers[i]), gp->width, gp->height);

			XSetForeground(display, gp->pixmap_gc, gp->background);
			XSetPlaneMask(display, gp->pixmap_gc, AllPlanes);
			XFillRectangle(display, gp->pixmap, gp->pixmap_gc, 0, 0,
				       gp->width, gp->height);
			XSetForeground(display, gp->pixmap_gc, ~0L);
			for (i = 0; i < gp->nlayers; i++) {
				XSetPlaneMask(display, gp->pixmap_gc, gp->layers[i].pixel);

#if 0
			XSetForeground (display, gp->pixmap_gc, ~0L);
			XFillRectangle (display, gp->pixmap, gp->pixmap_gc, 0, 0,
				gp->width, gp->height);
			XSetForeground (display, gp->pixmap_gc, 0L);
#endif
				draw_layer_blobs(display, gp->pixmap, gp->pixmap_gc,
				     &(gp->layers[i]), gp->width, gp->height,
						 True);
			}
			XCopyArea(display, gp->pixmap, window, MI_GC(mi), 0, 0,
				  gp->width, gp->height, 0, 0);
			break;

		case xored:
			XSetFunction(display, gp->pixmap_gc, GXcopy);
			XSetForeground(display, gp->pixmap_gc, 0);
			XFillRectangle(display, gp->pixmap, gp->pixmap_gc, 0, 0,
				       gp->width, gp->height);
			XSetFunction(display, gp->pixmap_gc, GXxor);
			XSetForeground(display, gp->pixmap_gc, 1);
			for (i = 0; i < gp->nlayers; i++)
				draw_layer_blobs(display, gp->pixmap, gp->pixmap_gc,
				     &(gp->layers[i]), gp->width, gp->height,
						 (gp->mode != outline));
			XCopyPlane(display, gp->pixmap, window, MI_GC(mi), 0, 0,
				   gp->width, gp->height, 0, 0, 1L);
			break;

		case opaque:
		case outline:
			XSetForeground(display, gp->pixmap_gc, MI_BLACK_PIXEL(mi));
			XFillRectangle(display, gp->pixmap, gp->pixmap_gc, 0, 0,
				       gp->width, gp->height);
			for (i = 0; i < gp->nlayers; i++) {
				XSetForeground(display, gp->pixmap_gc, gp->layers[i].pixel);
				draw_layer_blobs(display, gp->pixmap, gp->pixmap_gc,
				     &(gp->layers[i]), gp->width, gp->height,
						 (gp->mode != outline));
			}
			XCopyArea(display, gp->pixmap, window, MI_GC(mi), 0, 0,
				  gp->width, gp->height, 0, 0);
			break;

		default:
			if (MI_IS_VERBOSE(mi)) {
				(void) fprintf(stderr,
					"Weirdness in draw_goop()\n");
				(void) fprintf(stderr,
					"gp->mode = %d\n", gp->mode);
			}
			break;
	}
}