Example #1
0
static void
draw_corners (struct state *st, Drawable w, struct throbber *t)
{
  int s = (t->size + t->thickness) / 2;
  XPoint points[3];

  if (t->y > s)
    {
      points[0].x = 0;        points[0].y = t->y - s;
      points[1].x = t->x - s; points[1].y = t->y - s;
      points[2].x = t->x - s; points[2].y = 0;
      XDrawLines (st->dpy, w, t->gc, points, countof(points), CoordModeOrigin);

      points[0].x = t->x + s;    points[0].y = 0;
      points[1].x = t->x + s;    points[1].y = t->y - s;
      points[2].x = t->max_size; points[2].y = t->y - s;
      XDrawLines (st->dpy, w, t->gc, points, countof(points), CoordModeOrigin);
    }

  if (t->x > s)
    {
      points[0].x = 0;        points[0].y = t->y + s;
      points[1].x = t->x - s; points[1].y = t->y + s;
      points[2].x = t->x - s; points[2].y = t->max_size;
      XDrawLines (st->dpy, w, t->gc, points, countof(points), CoordModeOrigin);

      points[0].x = t->x + s;    points[0].y = t->max_size;
      points[1].x = t->x + s;    points[1].y = t->y + s;
      points[2].x = t->max_size; points[2].y = t->y + s;
      XDrawLines (st->dpy, w, t->gc, points, countof(points), CoordModeOrigin);
    }
}
Example #2
0
void
drawpoly (int numpoints, int *polypoints)
{
  int i;
  XPoint *Points;
  Points = malloc (numpoints * sizeof (XPoint));
  if (Points == NULL)
    {
      TcGraphResult = grNoScanMem;
      return;
    }
  // Convert to viewport coordinates.
  for (i = 0; i < numpoints; i++)
    {
      Points[i].x = TcViewLeft + *polypoints++;
      Points[i].y = TcViewTop + *polypoints++;
    }
  // Now do the actual drawing.
  XLockDisplay (TcDisplay);
  XDrawLines (TcDisplay, TcPixmaps[TcActivePage], TcGc, Points, numpoints,
	      CoordModeOrigin);
  if (TcActivePage == TcVisualPage)
    {
      XDrawLines (TcDisplay, TcWindow, TcGc, Points, numpoints,
		  CoordModeOrigin);
      XSync (TcDisplay, False);
    }
  XUnlockDisplay (TcDisplay);
  free (Points);
}
Example #3
0
/*
 * Draws the saucer section of the spaceship.
 */
void Spaceship::drawSaucer(XPoint ref, int shipw, int shiph, GC gc, Display *display, Pixmap &buffer)
{
    palette->setColor(ColorHandler::LIGHT_GREY, gc);
    XFillRectangle(display, buffer, gc, ref.x, ref.y, (shipw/2), (shiph/10));
    palette->setColor(ColorHandler::GREY, gc);
    XDrawRectangle(display, buffer, gc, ref.x, ref.y, (shipw/2), (shiph/10));

    XPoint points[4] = {
        ref,
        {ref.x+shipw/6, ref.y-shiph/12},
        {ref.x+shipw/6+shipw/7, ref.y-shiph/12},
        {ref.x+shipw/2,ref.y}
    };
    palette->setColor(ColorHandler::LIGHT_GREY, gc);
    XFillPolygon(display, buffer, gc, points, 4, Convex, CoordModeOrigin);
    palette->setColor(ColorHandler::GREY, gc);
    XDrawLines(display, buffer, gc, points, 4, CoordModeOrigin);

    XPoint bPoints[5] = {
        {ref.x, ref.y+shiph/10},
        {ref.x+shipw/6, ref.y+shiph/10+shiph/11},
        {ref.x+shipw/6+shipw/4, ref.y+shiph/10+shiph/11},
        {ref.x+shipw/2, ref.y+shiph/10},
        {ref.x, ref.y+shiph/10}
    };

    palette->setColor(ColorHandler::LIGHT_GREY, gc);
    XFillPolygon(display, buffer, gc, bPoints, 5, Convex, CoordModeOrigin);
    palette->setColor(ColorHandler::GREY, gc);
    XDrawLines(display, buffer, gc, bPoints, 5, CoordModeOrigin);
}
Example #4
0
/*-------------------------------------------------------------
**	EraseHands
**		Erase clock hands.
*/
static void
EraseHands (
	DtClockGadget	w,
	struct tm *	tm )
{
	XmManagerWidget	mgr =	(XmManagerWidget) XtParent (w);
	Display	*	dpy =		XtDisplay (w);
	Window		win =		XtWindow (w);
	unsigned char	behavior =	G_Behavior (w);
	GC		gc;

	if (! XtIsManaged ((Widget)w) || w->clock.numseg <= 0)
		return;

	gc = G_ClockBackgroundGC (w);

/*	Erase old hands.
*/
	if (!tm || tm->tm_min != w->clock.otm.tm_min ||
		  tm->tm_hour != w->clock.otm.tm_hour)
 	{ 
		XDrawLines (dpy, win, gc, w->clock.segbuff,
				VERTICES_IN_HANDS, CoordModeOrigin);
		XDrawLines (dpy, win, gc, w->clock.hour,
				VERTICES_IN_HANDS, CoordModeOrigin);
		XFillPolygon (dpy, win, gc, w->clock.segbuff,
				VERTICES_IN_HANDS, Convex, CoordModeOrigin);
		XFillPolygon (dpy, win, gc, w->clock.hour,
				VERTICES_IN_HANDS, Convex, CoordModeOrigin);
	}
}
Example #5
0
void xf_gdi_polyline(rdpUpdate* update, POLYLINE_ORDER* polyline)
{
	int i;
	int x, y;
	int x1, y1;
	int x2, y2;
	int npoints;
	uint32 color;
	XPoint* points;
	int width, height;
	xfInfo* xfi = GET_XFI(update);

	xf_set_rop2(xfi, polyline->bRop2);
	color = freerdp_color_convert(polyline->penColor, xfi->srcBpp, 32, xfi->clrconv);

	XSetFillStyle(xfi->display, xfi->gc, FillSolid);
	XSetForeground(xfi->display, xfi->gc, color);

	npoints = polyline->numPoints + 1;
	points = xmalloc(sizeof(XPoint) * npoints);

	points[0].x = polyline->xStart;
	points[0].y = polyline->yStart;

	for (i = 0; i < polyline->numPoints; i++)
	{
		points[i + 1].x = polyline->points[i].x;
		points[i + 1].y = polyline->points[i].y;
	}

	XDrawLines(xfi->display, xfi->drawing, xfi->gc, points, npoints, CoordModePrevious);

	if (xfi->drawing == xfi->primary)
	{
		if (xfi->remote_app != True)
			XDrawLines(xfi->display, xfi->drawable, xfi->gc, points, npoints, CoordModePrevious);

		x1 = points[0].x;
		y1 = points[0].y;

		for (i = 1; i < npoints; i++)
		{
			x2 = points[i].x + x1;
			y2 = points[i].y + y1;

			x = (x2 < x1) ? x2 : x1;
			width = (x2 > x1) ? x2 - x1 : x1 - x2;
		
			y = (y2 < y1) ? y2 : y1;
			height = (y2 > y1) ? y2 - y1 : y1 - y2;

			x1 = x2;
			y1 = y2;

			gdi_InvalidateRegion(xfi->hdc, x, y, width, height);
		}
	}

	xfree(points);
}
Example #6
0
void xf_gdi_polyline(rdpUpdate* update, POLYLINE_ORDER* polyline)
{
	int i;
	uint32 color;
	XPoint* points;
	xfInfo* xfi = GET_XFI(update);

	xf_set_rop2(xfi, polyline->bRop2);
	color = freerdp_color_convert(polyline->penColor, xfi->srcBpp, 32, xfi->clrconv);

	XSetFillStyle(xfi->display, xfi->gc, FillSolid);
	XSetForeground(xfi->display, xfi->gc, color);

	points = xmalloc(sizeof(XPoint) * polyline->numPoints);

	for (i = 0; i < polyline->numPoints; i++)
	{
		points[i].x = polyline->points[i].x;
		points[i].y = polyline->points[i].y;
	}

	XDrawLines(xfi->display, xfi->drawing, xfi->gc, points, polyline->numPoints, CoordModePrevious);

	if (xfi->drawing == xfi->primary)
	{
		if (xfi->remote_app != True)
		{
			XDrawLines(xfi->display, xfi->drawable, xfi->gc, points, polyline->numPoints, CoordModePrevious);
		}
	}

	xfree(points);
}
Example #7
0
void  WPigDrawPolyLine(const int *NPoints, const double *xarray, const double *yarray)
{
/*printf("void  WPigDrawPolyLine(Long *NPoints, float *xarray, float *yarray)(NPoints = %li)\n",
        (long) *NPoints);*/

/*XSetForeground (XtDisplay (MainCanvas), gc,BlackPixelOfScreen (XtScreen (MainCanvas)));*/

#define MAXFASTPOINTS 5
    if(*NPoints <= MAXFASTPOINTS) {
        int NumPoints;
        static  XPoint  points[MAXFASTPOINTS];

        for (NumPoints = 0; NumPoints < (int) *NPoints; NumPoints++) {

            points[NumPoints].x = 0.5*width + (xarray[NumPoints]-WCentx)*WtoVScale;
            points[NumPoints].y = 0.5*height - (yarray[NumPoints]-WCenty)*WtoVScale;
        }

         XDrawLines(XtDisplay(MainCanvas), XtWindow(MainCanvas),
                     gc, points, (int)*NPoints, CoordModeOrigin);
         if (use_pixmap)
        	 XDrawLines(XtDisplay(MainCanvas), pixmap, gc, points,
        			 (int)*NPoints, CoordModeOrigin);

#undef MAXFASTPOINTS
    } else {
/* #define MAXFASTPOINTS 8192 */
#define MAXFASTPOINTS 512
/* #define MAXFASTPOINTS (*NPoints+1) */
        int NumPoints, n;
        int j;
        static  XPoint  points[MAXFASTPOINTS];
//        short   x, y;
 //       double  xd, yd;

        for (j= 0; j < *NPoints; j += MAXFASTPOINTS - 1) {
            n = ((*NPoints - j) < MAXFASTPOINTS) ? (*NPoints - j) : MAXFASTPOINTS;

            for (NumPoints = 0; NumPoints < n; NumPoints++) {

            points[NumPoints].x = 0.5*width + (xarray[j+NumPoints]-WCentx)*WtoVScale;
            points[NumPoints].y = 0.5*height - (yarray[j+NumPoints]-WCenty)*WtoVScale;

            }

            XDrawLines(XtDisplay(MainCanvas), XtWindow(MainCanvas), gc,
                        points, n, CoordModeOrigin);
            if (use_pixmap)
            	XDrawLines(XtDisplay(MainCanvas), pixmap, gc, points, n, CoordModeOrigin);

        }
        /* pause(); */
#undef MAXFASTPOINTS
    }
/*    XSetForeground(XtDisplay(MainCanvas), gc, CmsColourDefs[XForegrColour]);*/
}
Example #8
0
/* draw lines between float points (with clipping) */
void FXDrawLines(Display *display, Drawable d, FGC fgc,
	FXPoint fpoints[], int npoints, int mode)
{
	int i,nbuf,flush;
	float x1,y1,x2,y2,cx1,cy1,cx2,cy2;
	FXPoint *fbuf;
	XPoint *points,pbuf[NPBUF];
	if (npoints>NPBUF)
		points = (XPoint *)malloc(npoints*sizeof(*points));
	else
		points = pbuf;
	if (fgc->clip) {
		fbuf = malloc(npoints*sizeof(*fbuf));
		flush = nbuf = 0;
		x2 = fpoints[0].fx;
		y2 = fpoints[0].fy;
		for (i=1; i<npoints; ++i) {
			x1 = x2;
			y1 = y2;
			x2 = fpoints[i].fx;
			y2 = fpoints[i].fy;
			if (mode==CoordModePrevious) {
				x2 += x1;
				y2 += x1;
			}
			if (!FClipLine(fgc,x1,y1,x2,y2,&cx1,&cy1,&cx2,&cy2)) {
				continue;
			} else {
				if (nbuf==0) {
					fbuf[nbuf].fx = cx1;
					fbuf[nbuf].fy = cy1;
					nbuf++;
				}
				fbuf[nbuf].fx = cx2;
				fbuf[nbuf].fy = cy2;
				nbuf++;
			}
			if (cx2!=x2 || cy2!=y2 || i==npoints-1) flush = 1;
			if (flush && nbuf>0) {
				FMapFPoints(fgc,fbuf,nbuf,points);
				XDrawLines(display,d,fgc->gc,points,nbuf,
					CoordModeOrigin);
				flush = nbuf = 0;
			}
		}
		free(fbuf);
	} else {
		FMapFPoints(fgc,fpoints,npoints,points);
		XDrawLines(display,d,fgc->gc,points,npoints,mode);
	}
	if (npoints>NPBUF) free(points);
}
Example #9
0
static void TabElementDraw(
    void *clientData, void *elementRecord, Tk_Window tkwin,
    Drawable d, Ttk_Box b, unsigned int state)
{
    TabElement *tab = elementRecord;
    Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, tab->backgroundObj);
    int borderWidth = 1;
    int cut = 2;
    XPoint pts[6];
    int n = 0;

    Tcl_GetIntFromObj(NULL, tab->borderWidthObj, &borderWidth);

    if (state & TTK_STATE_SELECTED) {
	/*
	 * Draw slightly outside of the allocated parcel,
	 * to overwrite the client area border.
	 */
	b.height += borderWidth;
    }

    pts[n].x = b.x; 			pts[n].y = b.y + b.height - 1; ++n;
    pts[n].x = b.x;			pts[n].y = b.y + cut; ++n;
    pts[n].x = b.x + cut;  		pts[n].y = b.y; ++n;
    pts[n].x = b.x + b.width-1-cut;	pts[n].y = b.y; ++n;
    pts[n].x = b.x + b.width-1; 	pts[n].y = b.y + cut; ++n;
    pts[n].x = b.x + b.width-1; 	pts[n].y = b.y + b.height; ++n;

    XFillPolygon(Tk_Display(tkwin), d,
	Tk_3DBorderGC(tkwin, border, TK_3D_FLAT_GC),
	pts, 6, Convex, CoordModeOrigin);

#ifndef WIN32
    /*
     * Account for whether XDrawLines draws endpoints by platform
     */
    --pts[5].y;
#endif

    while (borderWidth--) {
	XDrawLines(Tk_Display(tkwin), d,
		Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC),
		pts, 4, CoordModeOrigin);
	XDrawLines(Tk_Display(tkwin), d,
		Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC),
		pts+3, 3, CoordModeOrigin);
	++pts[0].x; ++pts[1].x; ++pts[2].x;             --pts[4].x; --pts[5].x;
	                        ++pts[2].y; ++pts[3].y;
    }

}
Example #10
0
static void
draw_thick_arrow (struct state *st, Drawable d, struct disc *disc,
                  int x, int y, int radius)
{
  XPoint points[10];
  double th;
  int radius2, radius3;
  double tick = ((M_PI * 2) / 72) * 2;

  radius *= 0.9;
  radius2 = radius - (radius / 8) * 3;
  radius3 = radius - (radius / 8) * 2;
  th = 2 * M_PI * (disc->theta / ((double) 360*64));

  points[0].x = x + radius * cos(th);		/* tip */
  points[0].y = y + radius * sin(th);

  points[1].x = x + radius2 * cos(th - tick);	/* tip left */
  points[1].y = y + radius2 * sin(th - tick);

  points[2].x = x + radius2 * cos(th + tick);	/* tip right */
  points[2].y = y + radius2 * sin(th + tick);

  points[3] = points[0];

  XDrawLines (st->dpy, d, disc->gc, points, 4, CoordModeOrigin);

  points[0].x = x + radius2 * cos(th - tick/2);	 /* top left */
  points[0].y = y + radius2 * sin(th - tick/2);

  points[1].x = x + -radius2 * cos(th + tick/2); /* bottom left */
  points[1].y = y + -radius2 * sin(th + tick/2);

  points[2].x = x + -radius3 * cos(th);		 /* bottom */
  points[2].y = y + -radius3 * sin(th);

  points[3].x = x + -radius * cos(th);		 /* bottom spike */
  points[3].y = y + -radius * sin(th);

  points[4] = points[2];			 /* return */

  points[5].x = x + -radius2 * cos(th - tick/2); /* bottom right */
  points[5].y = y + -radius2 * sin(th - tick/2);

  points[6].x = x + radius2 * cos(th + tick/2);  /* top right */
  points[6].y = y + radius2 * sin(th + tick/2);

  XDrawLines (st->dpy, d, disc->gc, points, 7, CoordModeOrigin);
}
Example #11
0
void draw_map() { //also drew the route
    int xcord, ycord;
    for (ycord = 0; ycord < MAP_SIZE; ycord++) {
        for (xcord = 0; xcord < MAP_SIZE; xcord++) {
            if (mappoints[xcord][ycord] == 1) {
                XDrawPoint(dis, win, blue_gc, (xcord + 50), (ycord + 50));
            }
        }
    }
    int allroutepoints[100];
    int i, j;
    int x, xx;
    int y, yy;
    int sizeorwhat;
    if (route_points != 0) {
        for (i = 1; i <= route_points; i++) {
            allroutepoints[i] = en_route_x[i] + en_route_y[i] * 1000; //x + 1000* y
        }

        for (j = 1; j < route_points; j++) {
            x = allroutepoints[j] % 1000;
            y = (allroutepoints[j] - x) / 1000;
            xx = allroutepoints[j + 1] % 1000;
            yy = (allroutepoints[j + 1] - xx) / 1000;
            XPoint points[] = {
                {(x + 50), (y + 50)},
                {(xx + 50), (yy + 50)},
            };
            sizeorwhat = sizeof (points) / sizeof (XPoint);
            XDrawLines(dis, win, green_gc, points, sizeorwhat, CoordModeOrigin);
        }
    }
}
Example #12
0
void iupDrawPolygon(IdrawCanvas* dc, int* points, int count, unsigned char r, unsigned char g, unsigned char b, int style)
{
    int i;
    XPoint* pnt = (XPoint*)malloc(count*sizeof(XPoint)); /* XPoint uses short for coordinates */

    for (i = 0; i < count; i++)
    {
        pnt[i].x = (short)points[2*i];
        pnt[i].y = (short)points[2*i+1];
    }

    XSetForeground(iupmot_display, dc->pixmap_gc, iupmotColorGetPixel(r, g, b));

    if (style==IUP_DRAW_FILL)
        XFillPolygon(iupmot_display, dc->pixmap, dc->pixmap_gc, pnt, count, Complex, CoordModeOrigin);
    else
    {
        XGCValues gcval;
        if (style==IUP_DRAW_STROKE_DASH)
            gcval.line_style = LineOnOffDash;
        else
            gcval.line_style = LineSolid;
        XChangeGC(iupmot_display, dc->pixmap_gc, GCLineStyle, &gcval);

        XDrawLines(iupmot_display, dc->pixmap, dc->pixmap_gc, pnt, count, CoordModeOrigin);
    }

    free(pnt);
}
Example #13
0
x_wglpli(int nbPoints, int polygone[][2])
{
   int i;
   XPoint p[256], *xptr, *largeP;
   
   if (nbPoints > 256)
      {
      largeP = (XPoint *) calloc(nbPoints, sizeof(XPoint));
      xptr = largeP;
      }
   else
      {
      xptr = p;
      }

   x_wglfshlb();
   for (i=0; i < nbPoints; i++)
      {
      xptr[i].x = polygone[i][X];
      xptr[i].y = h - polygone[i][Y];
      }

   XDrawLines(wglDisp, wglDrawable, wglLineGC, xptr, nbPoints, CoordModeOrigin);
   if (nbPoints > 256)
      free(largeP);

   }
Example #14
0
static void DisplayPolyF(
  Display		*dpy,
  Window		win,
  GC			gc,
  WlzPolygonDomain	*poly)
{
  WlzFVertex2	*fvtxs;
  int		i;

  /* check the polygon */
  if( poly == NULL ){
    return;
  }

  /* copy to an X line list */
  fvtxs = (WlzFVertex2 *) poly->vtx;
  for(i=0; (i < poly->nvertices) && (i < MAXXPOINTS); i++, fvtxs++){
    xpoints[i].x = fvtxs->vtX;
    xpoints[i].y = fvtxs->vtY;
  }

  /* display the polyline */
  XDrawLines(dpy, win, gc, xpoints, i, CoordModeOrigin);
  XFlush( dpy );
  return;
}
Example #15
0
/* 36% of execution time */
static void
drawImage(struct state *st)
{
#if 0
    int    q;
    XPoint *old0, *old1, *new0, *new1;

    /* Problem: update the window without too much flickering. I do
     * this by handling each linesegment separately. First remove a
     * line, then draw the new line. The problem is that this leaves
     * small black pixels on the figure. To fix this, we draw the
     * entire figure using XDrawLines() afterwards. */
    if (st->aPrev) {
	old0 = st->aPrev;
	old1 = st->aPrev + 1;
	new0 = st->aCurr;
	new1 = st->aCurr + 1;
	for (q = st->numPoints - 1; q; q--) {
	   XDrawLine(st->dpy, st->window, st->gcClear,
	     old0->x, old0->y, old1->x, old1->y); 
	    XDrawLine(st->dpy, st->window, st->gcDraw,
		      new0->x, new0->y, new1->x, new1->y);
	    ++old0;
	    ++old1;
	    ++new0;
	    ++new1;
	}
    }
#else
    XClearWindow(st->dpy,st->window);
#endif
    XDrawLines(st->dpy, st->window, st->gcDraw, st->aCurr, st->numPoints, CoordModeOrigin);
}
Example #16
0
void NSPlate::rect3D(Mode m, int x, int y, unsigned int w, unsigned int h)
{
  GC upperLeft, bottomRight;
  switch (m) {
  case up: upperLeft = bRimGC; bottomRight = dRimGC; break;
  case down: upperLeft = dRimGC; bottomRight = bRimGC; break;
  case flat: default: upperLeft = bottomRight = bgGC; break;
  }

  for (int i = 0; i < _thickness; i++) {
    short xa = x + i, ya = y + i, xe = x + w - i, ye = y + h - i;
    XPoint xp[5] = { {xa,ye}, {xa,ya}, {xe,ya}, {xe,ye}, {xa,ye}};
    XDrawLines(NSdpy, window(), upperLeft, xp, 3, CoordModeOrigin);
    XDrawLines(NSdpy, window(), bottomRight, xp+2, 3, CoordModeOrigin);
  }
}
Example #17
0
void XDrawRoundRect(Display *disp, Window win, GC gc,
                    int x, int y, int w, int h)
{
#define RAD (OFFS_X/2)
#define SetPoint(pn, x0, y0) pn.x = x0; pn.y = y0

    if ((w < 10) || (h < 10))
    {
        XDrawRectangle(disp, win, gc, x, y, w, h);
    }
    else
    {
        XPoint p[9];

        SetPoint(p[0], x+RAD, y);
        SetPoint(p[1], w-2*RAD, 0);
        SetPoint(p[2], RAD, RAD);
        SetPoint(p[3], 0, h-2*RAD);
        SetPoint(p[4], -RAD, RAD);
        SetPoint(p[5], 2*RAD-w, 0);
        SetPoint(p[6], -RAD, -RAD);
        SetPoint(p[7], 0, 2*RAD-h);
        SetPoint(p[8], RAD, -RAD);
        XDrawLines(disp, win, gc, p, 9, CoordModePrevious);
    }
}
Example #18
0
static void
circle(		/* indicate a solid angle on image */
    FVECT	dir,
    double	dom
)
{
    FVECT	start, cur;
    XPoint	pt[NSEG+1];
    FVECT	pp;
    int	ip[2];
    register int	i;

    fcross(cur, dir, ourview.vup);
    if (normalize(cur) == 0.0)
        goto fail;
    spinvector(start, dir, cur, acos(1.-dom/(2.*PI)));
    for (i = 0; i <= NSEG; i++) {
        spinvector(cur, start, dir, 2.*PI*i/NSEG);
        cur[0] += ourview.vp[0];
        cur[1] += ourview.vp[1];
        cur[2] += ourview.vp[2];
        viewloc(pp, &ourview, cur);
        if (pp[2] <= 0.0)
            goto fail;
        loc2pix(ip, &pres, pp[0], pp[1]);
        pt[i].x = ip[0];
        pt[i].y = ip[1];
    }
    XDrawLines(theDisplay, gwind, vecGC, pt, NSEG+1, CoordModeOrigin);
    return;
fail:
    fprintf(stderr, "%s: cannot draw source at (%f,%f,%f)\n",
            progname, dir[0], dir[1], dir[2]);
}
Example #19
0
static void
draw_star (struct state *st, Drawable w, struct throbber *t)
{
  XPoint points[11];
  int x = t->x;
  int y = t->y;

  /*
    The following constant is really:
      sqrt(5 - sqrt(5)) / sqrt(25 - 11 * sqrt(5))

    Reference: http://mathworld.wolfram.com/Pentagram.html
  */
  int s = t->size * 2.6180339887498985;
  int s2 = t->size;
  double c = M_PI * 2;
  double o = -M_PI / 2;

  points[0].x = x + s  * cos(o + 0.0*c); points[0].y = y + s  * sin(o + 0.0*c);
  points[1].x = x + s2 * cos(o + 0.1*c); points[1].y = y + s2 * sin(o + 0.1*c);
  points[2].x = x + s  * cos(o + 0.2*c); points[2].y = y + s  * sin(o + 0.2*c);
  points[3].x = x + s2 * cos(o + 0.3*c); points[3].y = y + s2 * sin(o + 0.3*c);
  points[4].x = x + s  * cos(o + 0.4*c); points[4].y = y + s  * sin(o + 0.4*c);
  points[5].x = x + s2 * cos(o + 0.5*c); points[5].y = y + s2 * sin(o + 0.5*c);
  points[6].x = x + s  * cos(o + 0.6*c); points[6].y = y + s  * sin(o + 0.6*c);
  points[7].x = x + s2 * cos(o + 0.7*c); points[7].y = y + s2 * sin(o + 0.7*c);
  points[8].x = x + s  * cos(o + 0.8*c); points[8].y = y + s  * sin(o + 0.8*c);
  points[9].x = x + s2 * cos(o + 0.9*c); points[9].y = y + s2 * sin(o + 0.9*c);
  points[10] = points[0];

  XDrawLines (st->dpy, w, t->gc, points, countof(points), CoordModeOrigin);
}
Example #20
0
int Polygon_DX (double *x, double *y, int npts)
{

   XPoint xpoint[1000] ;
   int k ;

   if (npts <= 0) return 0 ;

   if (npts > 1000) {
      printf("\nPolygon+X has been asked to deal with %d points.\n",
             npts) ;
      printf("Points past first 1000 ignored.\n") ;
      npts = 1000 ;
   }

   for (k = 0 ; k < npts ; k++) {
        xpoint[k].x = (int)x[k] ;
        xpoint[k].y = (int)(TheHeight -1 - y[k]) ;
   }

   XDrawLines(TheDisplay,TheDrawable,ThePixmapContext,
                       xpoint,npts,  CoordModeOrigin);
   XDrawLine(TheDisplay,TheDrawable,ThePixmapContext,
                    xpoint[0].x, xpoint[0].y,
                         xpoint[npts-1].x, xpoint[npts-1].y ) ;

   return 1 ;
}
Example #21
0
  void drawPolygon(XPoint *points, int npoints, Color fill_color, bool fill, unsigned int line_width, int line_style, int cap_style, int join_style, int fill_rule, int function){

    gc_vals.foreground = fill_color;
    gc_vals.line_width = line_width;
    gc_vals.fill_rule = fill_rule;
    XChangeGC(display, gc, GCForeground | GCLineWidth | GCFillRule, &gc_vals);

    //  XSync(display, false);


    if(fill)
      XFillPolygon(display, curr_d, gc, points, npoints, 
		   Complex, CoordModeOrigin);
    else{

      XPoint pts[npoints + 1];
      int iter;

      // Create array with closed list
      for(iter = 0; iter < npoints; iter ++){
	pts[iter] = points[iter];
      }

      pts[iter] = points[0];

      XDrawLines(display, curr_d, gc, pts, npoints + 1, CoordModeOrigin);
    }

    //XSync(display, false);

  }
Example #22
0
/*public*/
void TtkDrawArrow(
    Display *display, Drawable d, GC gc, Ttk_Box b, ArrowDirection dir)
{
    XPoint points[4];
    ArrowPoints(b, dir, points);
    XDrawLines(display, d, gc, points, 4, CoordModeOrigin);
}
Example #23
0
/*
 * Draws a segment of a single trace. We draw 'samples' points from the 'tr'
 * trace array to pixel coordinates (x,y) with scale xs, ys.
 *
 * The confidence display is quite wide, and draws more than x0-xn.
 * To compensate, we need to increase x0-xn.
 */
static void trace_draw2(DNATrace *t, TRACE *tr, Display *d, Pixmap p, int max,
			GC gc, int x0, int xn, int yoff, int height, double ys,
			int off, int sign) {
    int i, h = height-1, o;
    XPoint *xp, *xp2;

    if (xn <= 0 || NULL == (xp = (XPoint *)xmalloc(xn * sizeof(XPoint)))) {
	return;
    }

    o = t->disp_offset * t->scale_x;

    if (t->read->maxTraceVal)
	h -= h*(double)off/t->read->maxTraceVal;
    for (i = 0; i < xn; i++, tr++) {
	xp[i].x = (int)((x0 + i) * t->scale_x) - o;
	if (sign) {
	    xp[i].y = h - ys * ((int_2)*tr-off) + yoff;
	} else {
	    xp[i].y = h - ys * (*tr-off) + yoff;
	}
    }

    for (i = 0; i < xn; i++)
        if (xp[i].x >= 0)
            break;
    xp2 = &xp[i];
    xn -= i;

    if (xn > 0) {
	XDrawLines(d, p, gc, xp2, xn, CoordModeOrigin);
    }

    xfree(xp);
}
Example #24
0
int 
InitScroll(XParms xp, Parms p, int reps)
{
    InitBltLines();
    XDrawLines(xp->d, xp->w, xp->fggc, points, NUMPOINTS, CoordModeOrigin);
    return reps;
}
Example #25
0
int
InitCopyPlane(XParms xp, Parms p, int reps)
{
    XGCValues   gcv;
    GC		pixgc;

    InitBltLines();
    InitCopyLocations(xp, p, reps);

    /* Create pixmap to write stuff into, and initialize it */
    pix = XCreatePixmap(xp->d, xp->w, WIDTH, HEIGHT, 
	    p->font==NULL ? 1 : xp->vinfo.depth);
    gcv.graphics_exposures = False;
    gcv.foreground = 0;
    gcv.background = 1;
    pixgc = XCreateGC(xp->d, pix, 
		GCForeground | GCBackground | GCGraphicsExposures, &gcv);
    XFillRectangle(xp->d, pix, pixgc, 0, 0, WIDTH, HEIGHT);
    gcv.foreground = 1;
    gcv.background = 0;
    XChangeGC(xp->d, pixgc, GCForeground | GCBackground, &gcv);
    XDrawLines(xp->d, pix, pixgc, points, NUMPOINTS, CoordModeOrigin);
    XFreeGC(xp->d, pixgc);

    return reps;
}
Example #26
0
/*
 * Class:     sun_java2d_x11_X11Renderer
 * Method:    XDrawPoly
 * Signature: (IJII[I[IIZ)V
 */
JNIEXPORT void JNICALL Java_sun_java2d_x11_X11Renderer_XDrawPoly
    (JNIEnv *env, jobject xr,
     jlong pXSData, jlong xgc,
     jint transx, jint transy,
     jintArray xcoordsArray, jintArray ycoordsArray, jint npoints,
     jboolean isclosed)
{
#ifndef HEADLESS
    XPoint pTmp[POLYTEMPSIZE], *points;
    X11SDOps *xsdo = (X11SDOps *) pXSData;

    if (xsdo == NULL) {
        return;
    }

    if (JNU_IsNull(env, xcoordsArray) || JNU_IsNull(env, ycoordsArray)) {
        JNU_ThrowNullPointerException(env, "coordinate array");
        return;
    }
    if ((*env)->GetArrayLength(env, ycoordsArray) < npoints ||
        (*env)->GetArrayLength(env, xcoordsArray) < npoints)
    {
        JNU_ThrowArrayIndexOutOfBoundsException(env, "coordinate array");
        return;
    }

    if (npoints < 2) {
        return;
    }

    points = transformPoints(env, xcoordsArray, ycoordsArray, transx, transy,
                             pTmp, (int *)&npoints, isclosed);
    if (points == 0) {
        JNU_ThrowOutOfMemoryError(env, "translated coordinate array");
    } else {
        if (npoints == 2) {
            /*
             * Some X11 implementations fail to draw anything for
             * simple 2 point polygons where the vertices are the
             * same point even though this violates the X11
             * specification.  For simplicity we will dispatch all
             * 2 point polygons through XDrawLine even if they are
             * non-degenerate as this may invoke less processing
             * down the line than a Poly primitive anyway.
             */
            XDrawLine(awt_display, xsdo->drawable, (GC) xgc,
                      points[0].x, points[0].y,
                      points[1].x, points[1].y);
        } else {
            XDrawLines(awt_display, xsdo->drawable, (GC) xgc,
                       points, npoints, CoordModeOrigin);
        }
        if (points != pTmp) {
            free(points);
        }
        X11SD_DirectRenderNotify(env, xsdo);
    }
#endif /* !HEADLESS */
}
Example #27
0
 void Graphics::DrawPolygon(const vector<Point> & vertices)
 {
   this->PrepareGraphicsContext();
   XPoint* xPoints = this->GetTransformedXPoints(vertices);
   XDrawLines(this->display, this->window, this->gc, xPoints, vertices.size(), CoordModeOrigin);
   delete[] xPoints;
   DebugDelay(string("DrawPolygon"));
 }
Example #28
0
inline void NSSelector::drawBorder()
{
  XPoint points[] = { {0, 0}, {NSWindow::width() - 1, 0},
                      {NSWindow::width() - 1, NSWindow::height() - 1},
                      {0, NSWindow::height() - 1}, {0, 0} };

  XDrawLines(NSdpy, window(), _gc, points, 5, CoordModeOrigin);
}
Example #29
0
void car_facing_up(int startx, int starty, int finy) {
    startx -= 10;
    starty -= 15;
    finy -= 10;
    int i;
    XClearWindow(dis, win);
    XFlush(dis);
    //draw triangle
    if (starty == finy) {
        i = starty;
        XPoint points[] = {
            {(startx), (i + 30)},
            {(startx + 10), (i + 45)},
            {(startx + 20), (i + 30)},
        };
        int npoints = sizeof (points) / sizeof (XPoint);
        //draw background first 
        XClearWindow(dis, win);
        draw_map();
        grid_map();
        //draw the car
        XDrawRectangle(dis, win, green_gc, startx, i, 20, 30);
        XDrawLines(dis, win, green_gc, points, npoints, CoordModeOrigin);
        XFlush(dis);

    } else {
        for (i = starty; i > finy; i -= 10) {
            XPoint points[] = {
                {(startx), (i)},
                {(startx + 10), (i - 15)},
                {(startx + 20), (i)},
            };
            int npoints = sizeof (points) / sizeof (XPoint);
            //draw background first 
            XClearWindow(dis, win);
            draw_map();
            grid_map();
            //draw the car
            XDrawRectangle(dis, win, green_gc, startx, i, 20, 30);
            XDrawLines(dis, win, green_gc, points, npoints, CoordModeOrigin);
            XFlush(dis);
        }
    }
}
Example #30
0
void
drawpoly(Image *dst, Point *pt, int np, int cap, int w, Color *col) {
	XPoint *xp;

	xp = convpts(pt, np);
	XSetLineAttributes(display, dst->gc, w, LineSolid, cap, JoinMiter);
	setgccol(dst, col);
	XDrawLines(display, dst->xid, dst->gc, xp, np, CoordModeOrigin);
	free(xp);
}