Example #1
0
void GrEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int style,GrColor c)
{
    int (*pnts)[2];
    setup_ALLOC();
    pnts = ALLOC(sizeof(int) * 2 * (GR_MAX_ELLIPSE_POINTS + 1));
    if (pnts != NULL)
    {
	GrFillArg fval;
	int npts  = GrGenerateEllipseArc(xc,yc,xa,ya,start,end,pnts);
	int close = FALSE;
	switch(style) {
	  case GR_ARC_STYLE_CLOSE2:
	    pnts[npts][0] = xc;
	    pnts[npts][1] = yc;
	    npts++;
	  case GR_ARC_STYLE_CLOSE1:
	    close = TRUE;
	    break;
	}
	fval.color = c;
	_GrDrawPolygon(npts,pnts,&_GrSolidFiller,fval,close);
	FREE(pnts);
    }
    reset_ALLOC();
}
Example #2
0
void GrPatternedEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int style,GrLinePattern *lp)
{
    int (*points)[2];
    setup_ALLOC();
    points = ALLOC(sizeof(int) * 2 * (GR_MAX_ELLIPSE_POINTS + 2));
    if (points != NULL)
    {
	int numpts = GrGenerateEllipseArc(xc,yc,xa,ya,start,end,points);
	GrFillArg fval;
	int close;

	close = FALSE;
	if (style == GR_ARC_STYLE_CLOSE2) {
		points[numpts][0] = xc;
		points[numpts][1] = yc;
		numpts++;
		points[numpts][0] = points[0][0];
		points[numpts][1] = points[0][1];
		numpts++;
		close = TRUE;
	}
	if (style == GR_ARC_STYLE_CLOSE1) {
		points[numpts][0] = points[0][0];
		points[numpts][1] = points[0][1];
		numpts++;
		close = TRUE;
	}
	fval.p = lp->lnp_pattern;
	_GrDrawCustomPolygon(numpts,points,lp->lnp_option,
			     &_GrPatternFiller,fval,close,TRUE);
	FREE(points);
    }
    reset_ALLOC();
}
Example #3
0
void GrCustomEllipse(int xc,int yc,int xa,int ya,const GrLineOption *o)
{
    int (*pnts)[2];
    setup_ALLOC();
    pnts = ALLOC(sizeof(int) * 2 * GR_MAX_ELLIPSE_POINTS);
    if (pnts != NULL)
    {
	GrFillArg fval;
	int npts  = GrGenerateEllipse(xc,yc,xa,ya,pnts);
	fval.color = o->lno_color;
	_GrDrawCustomPolygon(npts,pnts,o,&_GrSolidFiller,fval,TRUE,TRUE);
	FREE(pnts);
    }
    reset_ALLOC();
}
Example #4
0
/**
 * grx_user_draw_polyline:
 * @n_points: the number of points in @points
 * @points: (array length=n_points): an array of #GrxPoint
 * @c: the color
 *
 * Draw a multi-segment line on the current context that connects each point in
 * the @points array using the specified color.
 */
void grx_user_draw_polyline(int numpts,GrxPoint *points,GrxColor c)
{
        int pt;
        GrxPoint *tmp;
        setup_ALLOC();
        tmp = ALLOC(sizeof(GrxPoint) * numpts);

        if (tmp != NULL) {
          for ( pt = 0; pt < numpts; pt++) {
                tmp[pt] = points[pt];
                U2SX(tmp[pt].x,CURC);
                U2SY(tmp[pt].y,CURC);
          }
          grx_draw_polyline(numpts,tmp,c);
          FREE(tmp);
        }
        reset_ALLOC();
}
Example #5
0
void GrUsrPolygon(int numpts,int points[][2],GrColor c)
{
	int pt;
	int (*tmp)[2];
	setup_ALLOC();
	tmp = ALLOC(sizeof(int) * 2 * numpts);

	if (tmp != NULL) {
	  for ( pt = 0; pt < numpts; pt++) {
		tmp[pt][0] = points[pt][0];
		tmp[pt][1] = points[pt][1];
		U2SX(tmp[pt][0],CURC);
		U2SY(tmp[pt][1],CURC);
	  }
	  GrPolygon(numpts,tmp,c);
	  FREE(tmp);
	}
	reset_ALLOC();
}
Example #6
0
void GrSetFontPath(char *p)
{
	int  chr,totlen = 0,npath,plen = 0;
	char path[200],*plist[100];
	if(!p || (*p == '\0')) return;
        for (npath = 0; npath < itemsof(plist); ++npath)
          plist[npath] = NULL;
        npath = 0;
	setup_ALLOC();
	path[0] = '\0';
	while(((chr = *p++) != '\0') || (plen > 0)) {
	    int pathchr = TRUE;
	    switch(chr) {
	      case ':':
#ifdef __MSDOS__
		if((plen == 1) && isalpha(path[0])) break;
#endif
	      case ';':
		pathchr = FALSE;
		break;
	      case '\0':
		p--;
		pathchr = FALSE;
		break;
#ifdef __MSDOS__
	      case '\\':
		chr = '/';
		break;
#endif
	      default:
#ifdef __MSDOS__
		chr = tolower(chr);
#endif
		if(isspace(chr)) pathchr = FALSE;
		break;
	    }
	    if(pathchr) {
		path[plen++] = chr;
		continue;
	    }
	    if(plen > 0) {
		if(path[plen - 1] != '/') path[plen++] = '/';
		path[plen++] = '\0';
		plist[npath] = ALLOC((size_t)plen);
		if(plist[npath] == NULL) goto error;
		strcpy(plist[npath],path);
		totlen += plen;
		plen = 0;
		if(++npath == itemsof(plist)) break;
	    }
	}
	if(_GrFontFileInfo.path != NULL) free(_GrFontFileInfo.path);
	_GrFontFileInfo.path  = NULL;
	_GrFontFileInfo.npath = npath;
	if(npath > 0) {
	    _GrFontFileInfo.path = malloc((sizeof(char *) * npath) + totlen);
	    if(_GrFontFileInfo.path == NULL) goto error;
	    p = (char *)(&_GrFontFileInfo.path[npath]);
	    for(plen = 0; plen < npath; plen++) {
		_GrFontFileInfo.path[plen] = p;
		strcpy(p,plist[plen]);
		p += strlen(p) + 1;
	    }
	}
	goto done;
      error:
	if(_GrFontFileInfo.path != NULL) free(_GrFontFileInfo.path);
	_GrFontFileInfo.path  = NULL;
	_GrFontFileInfo.npath = 0;
      done:
        for (npath = 0; npath < itemsof(plist); ++npath)
          FREE(plist[npath]);
	reset_ALLOC();
}