Exemplo n.º 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();
}
Exemplo n.º 2
0
void GrPolyLine(int n,int pt[][2],GrColor c)
{
	GrFillArg fval;
	fval.color = c;
	_GrDrawPolygon(n,pt,&_GrSolidFiller,fval,FALSE);
}
Exemplo n.º 3
0
/**
 * grx_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_draw_polyline(int n,GrxPoint *pt,GrxColor c)
{
        GrFillArg fval;
        fval.color = c;
        _GrDrawPolygon(n,pt,&_GrSolidFiller,fval,FALSE);
}
Exemplo n.º 4
0
void _GrScanEllipse(int xc,int yc,int xa,int ya,GrFiller *f,GrFillArg c,int filled)
{
    int x1,x2,y1,y2;
    if(xa < 0) xa = (-xa);
    if(ya < 0) ya = (-ya);
    x1 = xc - xa;
    y1 = yc - ya;
    x2 = xc + xa;
    y2 = yc + ya;
    clip_ordbox(CURC,x1,y1,x2,y2);
    mouse_block(CURC,x1,y1,x2,y2);
    setup_ALLOC();
    if((xa == 0) || (ya == 0)) (*f->line)(
            (x1 + CURC->gc_xoffset),
            (y1 + CURC->gc_yoffset),
            (x2 - x1),
            (y2 - y1),
            c
        );
    else if((xa > MAXR) || (ya > MAXR)) {   /* Bresenham would overflow !! */
        int (*points)[2] = ALLOC(sizeof(int) * 2 * GR_MAX_ELLIPSE_POINTS);
        if(points != NULL) {
            int count = GrGenerateEllipse(xc,yc,xa,ya,points);
            if(filled) _GrScanConvexPoly(count,points,f,c);
            else       _GrDrawPolygon(count,points,f,c,TRUE);
            FREE(points);
        }
    }
    else {
        int *scans = ALLOC(sizeof(int) * (ya + 1));
        int  row   = ya;
        int  col   = 0;
        if(scans != NULL) {
            long yasq  = umul32(ya,ya);
            long xasq  = umul32(xa,xa);
            long xasq2 = xasq + xasq;
            long yasq2 = yasq + yasq;
            long xasq4 = xasq2 + xasq2;
            long yasq4 = yasq2 + yasq2;
            long error = (xasq2 * (row - 1) * row) +
                         (yasq2 * (1 - xasq))      +
                         xasq;
            while((xasq * row) > (yasq * col)) {
                if(error >= 0) {
                    scans[row] = col;
                    row--;
                    error -= xasq4 * row;
                }
                error += yasq2 * (3 + (col << 1));
                col++;
            }
            error = (yasq2 * (col + 1) * col)         +
                    (xasq2 * ((row * (row - 2)) + 1)) +
                    (yasq  * (1 - xasq2));
            while(row >= 0) {
                scans[row] = col;
                if(error <= 0) {
                    col++;
                    error += yasq4 * col;
                }
                row--;
                error += xasq2 * (2 - (row << 1));
            }
            for(row = y1; row <= y2; row++) {
                col = iabs(yc - row);
                if(!filled && (col < ya)) {
                    x1 = xc - scans[col];
                    x2 = xc - scans[col + 1];
                    if(x1 < x2) x2--;
                    do {
                        clip_ordxrange_(CURC,x1,x2,break,CLIP_EMPTY_MACRO_ARG);
                        (*f->scan)(
                            (x1  + CURC->gc_xoffset),
                            (row + CURC->gc_yoffset),
                            (x2  - x1 + 1),
                            c
                        );
                    } while (0);
                    x1 = xc + scans[col + 1];
                    x2 = xc + scans[col];
                    if(x1 < x2) x1++;
                }
                else {
                    x1 = xc - scans[col];
                    x2 = xc + scans[col];
                }
                clip_ordxrange_(CURC,x1,x2,continue,CLIP_EMPTY_MACRO_ARG);
                (*f->scan)(
                    (x1  + CURC->gc_xoffset),
                    (row + CURC->gc_yoffset),
                    (x2  - x1 + 1),
                    c
                );
            }