⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 miwideline.c

📁 远程桌面连接工具
💻 C
📖 第 1 页 / 共 4 页
字号:
    }    if (joinStyle == JoinMiter)    {	slopes[2].dx = pLeft->dx;	slopes[2].dy = pLeft->dy;	slopes[2].k =  pLeft->k;	if (swapslopes)	{	    slopes[2].dx = -slopes[2].dx;	    slopes[2].dy = -slopes[2].dy;	    slopes[2].k  = -slopes[2].k;	}	vertices[3].x = mx;	vertices[3].y = my;	slopes[3].dx = pRight->dx;	slopes[3].dy = pRight->dy;	slopes[3].k  = pRight->k;	if (swapslopes)	{	    slopes[3].dx = -slopes[3].dx;	    slopes[3].dy = -slopes[3].dy;	    slopes[3].k  = -slopes[3].k;	}	edgecount = 4;    }    else    {	double	scale, dx, dy, adx, ady;	adx = dx = pRight->xa - pLeft->xa;	ady = dy = pRight->ya - pLeft->ya;	if (adx < 0)	    adx = -adx;	if (ady < 0)	    ady = -ady;	scale = ady;	if (adx > ady)	    scale = adx;	slopes[2].dx = (dx * 65536) / scale;	slopes[2].dy = (dy * 65536) / scale;	slopes[2].k = ((pLeft->xa + pRight->xa) * slopes[2].dy -		       (pLeft->ya + pRight->ya) * slopes[2].dx) / 2.0;	edgecount = 3;    }    y = miPolyBuildPoly (vertices, slopes, edgecount, pLeft->x, pLeft->y,		   left, right, &nleft, &nright, &height);    miFillPolyHelper (pDrawable, pGC, pixel, spanData, y, height, left, right, nleft, nright);}static intmiLineArcI (pDraw, pGC, xorg, yorg, points, widths)    DrawablePtr	    pDraw;    GCPtr	    pGC;    int		    xorg, yorg;    DDXPointPtr	    points;    int		    *widths;{    register DDXPointPtr tpts, bpts;    register int *twids, *bwids;    register int x, y, e, ex, slw;    tpts = points;    twids = widths;    if (pGC->miTranslate)    {	xorg += pDraw->x;	yorg += pDraw->y;    }    slw = pGC->lineWidth;    if (slw == 1)    {	tpts->x = xorg;	tpts->y = yorg;	*twids = 1;	return 1;    }    bpts = tpts + slw;    bwids = twids + slw;    y = (slw >> 1) + 1;    if (slw & 1)	e = - ((y << 2) + 3);    else	e = - (y << 3);    ex = -4;    x = 0;    while (y)    {	e += (y << 3) - 4;	while (e >= 0)	{	    x++;	    e += (ex = -((x << 3) + 4));	}	y--;	slw = (x << 1) + 1;	if ((e == ex) && (slw > 1))	    slw--;	tpts->x = xorg - x;	tpts->y = yorg - y;	tpts++;	*twids++ = slw;	if ((y != 0) && ((slw > 1) || (e != ex)))	{	    bpts--;	    bpts->x = xorg - x;	    bpts->y = yorg + y;	    *--bwids = slw;	}    }    return (pGC->lineWidth);}#define CLIPSTEPEDGE(edgey,edge,edgeleft) \    if (ybase == edgey) \    { \	if (edgeleft) \	{ \	    if (edge->x > xcl) \		xcl = edge->x; \	} \	else \	{ \	    if (edge->x < xcr) \		xcr = edge->x; \	} \	edgey++; \	edge->x += edge->stepx; \	edge->e += edge->dx; \	if (edge->e > 0) \	{ \	    edge->x += edge->signdx; \	    edge->e -= edge->dy; \	} \    }static intmiLineArcD (pDraw, pGC, xorg, yorg, points, widths,	    edge1, edgey1, edgeleft1, edge2, edgey2, edgeleft2)    DrawablePtr	    pDraw;    GCPtr	    pGC;    double	    xorg, yorg;    DDXPointPtr	    points;    int		    *widths;    PolyEdgePtr	    edge1, edge2;    int		    edgey1, edgey2;    Bool	    edgeleft1, edgeleft2;{    register DDXPointPtr pts;    register int *wids;    double radius, x0, y0, el, er, yk, xlk, xrk, k;    int xbase, ybase, y, boty, xl, xr, xcl, xcr;    int ymin, ymax;    Bool edge1IsMin, edge2IsMin;    int ymin1, ymin2;    pts = points;    wids = widths;    xbase = floor(xorg);    x0 = xorg - xbase;    ybase = ICEIL (yorg);    y0 = yorg - ybase;    if (pGC->miTranslate)    {	xbase += pDraw->x;	ybase += pDraw->y;	edge1->x += pDraw->x;	edge2->x += pDraw->x;	edgey1 += pDraw->y;	edgey2 += pDraw->y;    }    xlk = x0 + x0 + 1.0;    xrk = x0 + x0 - 1.0;    yk = y0 + y0 - 1.0;    radius = ((double)pGC->lineWidth) / 2.0;    y = floor(radius - y0 + 1.0);    ybase -= y;    ymin = ybase;    ymax = 65536;    edge1IsMin = FALSE;    ymin1 = edgey1;    if (edge1->dy >= 0)    {    	if (!edge1->dy)    	{	    if (edgeleft1)	    	edge1IsMin = TRUE;	    else	    	ymax = edgey1;	    edgey1 = 65536;    	}    	else    	{	    if ((edge1->signdx < 0) == edgeleft1)	    	edge1IsMin = TRUE;    	}    }    edge2IsMin = FALSE;    ymin2 = edgey2;    if (edge2->dy >= 0)    {    	if (!edge2->dy)    	{	    if (edgeleft2)	    	edge2IsMin = TRUE;	    else	    	ymax = edgey2;	    edgey2 = 65536;    	}    	else    	{	    if ((edge2->signdx < 0) == edgeleft2)	    	edge2IsMin = TRUE;    	}    }    if (edge1IsMin)    {	ymin = ymin1;	if (edge2IsMin && ymin1 > ymin2)	    ymin = ymin2;    } else if (edge2IsMin)	ymin = ymin2;    el = radius * radius - ((y + y0) * (y + y0)) - (x0 * x0);    er = el + xrk;    xl = 1;    xr = 0;    if (x0 < 0.5)    {	xl = 0;	el -= xlk;    }    boty = (y0 < -0.5) ? 1 : 0;    if (ybase + y - boty > ymax)	boty = ymax - ybase - y;    while (y > boty)    {	k = (y << 1) + yk;	er += k;	while (er > 0.0)	{	    xr++;	    er += xrk - (xr << 1);	}	el += k;	while (el >= 0.0)	{	    xl--;	    el += (xl << 1) - xlk;	}	y--;	ybase++;	if (ybase < ymin)	    continue;	xcl = xl + xbase;	xcr = xr + xbase;	CLIPSTEPEDGE(edgey1, edge1, edgeleft1);	CLIPSTEPEDGE(edgey2, edge2, edgeleft2);	if (xcr >= xcl)	{	    pts->x = xcl;	    pts->y = ybase;	    pts++;	    *wids++ = xcr - xcl + 1;	}    }    er = xrk - (xr << 1) - er;    el = (xl << 1) - xlk - el;    boty = floor(-y0 - radius + 1.0);    if (ybase + y - boty > ymax)	boty = ymax - ybase - y;    while (y > boty)    {	k = (y << 1) + yk;	er -= k;	while ((er >= 0.0) && (xr >= 0))	{	    xr--;	    er += xrk - (xr << 1);	}	el -= k;	while ((el > 0.0) && (xl <= 0))	{	    xl++;	    el += (xl << 1) - xlk;	}	y--;	ybase++;	if (ybase < ymin)	    continue;	xcl = xl + xbase;	xcr = xr + xbase;	CLIPSTEPEDGE(edgey1, edge1, edgeleft1);	CLIPSTEPEDGE(edgey2, edge2, edgeleft2);	if (xcr >= xcl)	{	    pts->x = xcl;	    pts->y = ybase;	    pts++;	    *wids++ = xcr - xcl + 1;	}    }    return (pts - points);}intmiRoundJoinFace (face, edge, leftEdge)    register LineFacePtr face;    register PolyEdgePtr edge;    Bool	*leftEdge;{    int	    y;    int	    dx, dy;    double  xa, ya;    Bool	left;    dx = -face->dy;    dy = face->dx;    xa = face->xa;    ya = face->ya;    left = 1;    if (ya > 0)    {	ya = 0.0;	xa = 0.0;    }    if (dy < 0 || dy == 0 && dx > 0)    {	dx = -dx;	dy = -dy;	left = !left;    }    if (dx == 0 && dy == 0)	dy = 1;    if (dy == 0)    {	y = ICEIL (face->ya) + face->y;	edge->x = -32767;	edge->stepx = 0;	edge->signdx = 0;	edge->e = -1;	edge->dy = 0;	edge->dx = 0;	edge->height = 0;    }    else    {	y = miPolyBuildEdge (xa, ya, 0.0, dx, dy, face->x, face->y, !left, edge);	edge->height = 32767;    }    *leftEdge = !left;    return y;}voidmiRoundJoinClip (pLeft, pRight, edge1, edge2, y1, y2, left1, left2)    register LineFacePtr pLeft, pRight;    PolyEdgePtr	edge1, edge2;    int		*y1, *y2;    Bool	*left1, *left2;{    double	denom;    denom = - pLeft->dx * (double)pRight->dy + pRight->dx * (double)pLeft->dy;    if (denom >= 0)    {	pLeft->xa = -pLeft->xa;	pLeft->ya = -pLeft->ya;    }    else    {	pRight->xa = -pRight->xa;	pRight->ya = -pRight->ya;    }    *y1 = miRoundJoinFace (pLeft, edge1, left1);    *y2 = miRoundJoinFace (pRight, edge2, left2);}intmiRoundCapClip (face, isInt, edge, leftEdge)    register LineFacePtr face;    Bool	isInt;    register PolyEdgePtr edge;    Bool	*leftEdge;{    int	    y;    register int dx, dy;    double  xa, ya, k;    Bool	left;    dx = -face->dy;    dy = face->dx;    xa = face->xa;    ya = face->ya;    k = 0.0;    if (!isInt)	k = face->k;    left = 1;    if (dy < 0 || dy == 0 && dx > 0)    {	dx = -dx;	dy = -dy;	xa = -xa;	ya = -ya;	left = !left;    }    if (dx == 0 && dy == 0)	dy = 1;    if (dy == 0)    {	y = ICEIL (face->ya) + face->y;	edge->x = -32767;	edge->stepx = 0;	edge->signdx = 0;	edge->e = -1;	edge->dy = 0;	edge->dx = 0;	edge->height = 0;    }    else    {	y = miPolyBuildEdge (xa, ya, k, dx, dy, face->x, face->y, !left, edge);	edge->height = 32767;    }    *leftEdge = !left;    return y;}static voidmiLineArc (pDraw, pGC, pixel, spanData, leftFace, rightFace, xorg, yorg, isInt)    DrawablePtr	    pDraw;    register GCPtr  pGC;    unsigned long   pixel;    SpanDataPtr	    spanData;    register LineFacePtr leftFace, rightFace;    double	    xorg, yorg;    Bool	    isInt;{    DDXPointPtr points;    int *widths;    int xorgi, yorgi;    XID		oldPixel;    Spans spanRec;    int n;    PolyEdgeRec	edge1, edge2;    int		edgey1, edgey2;    Bool	edgeleft1, edgeleft2;    if (isInt)    {	xorgi = leftFace ? leftFace->x : rightFace->x;	yorgi = leftFace ? leftFace->y : rightFace->y;    }    edgey1 = 65536;    edgey2 = 65536;    edge1.x = 0; /* not used, keep memory checkers happy */    edge1.dy = -1;    edge2.x = 0; /* not used, keep memory checkers happy */    edge2.dy = -1;    edgeleft1 = FALSE;    edgeleft2 = FALSE;    if ((pGC->lineStyle != LineSolid || pGC->lineWidth > 2) &&	(pGC->capStyle == CapRound && pGC->joinStyle != JoinRound ||	 pGC->joinStyle == JoinRound && pGC->capStyle == CapButt))    {	if (isInt)	{	    xorg = (double) xorgi;	    yorg = (double) yorgi;	}	if (leftFace && rightFace)	{	    miRoundJoinClip (leftFace, rightFace, &edge1, &edge2,			     &edgey1, &edgey2, &edgeleft1, &edgeleft2);	}	else if (leftFace)	{	    edgey1 = miRoundCapClip (leftFace, isInt, &edge1, &edgeleft1);	}	else if (rightFace)	{	    edgey2 = miRoundCapClip (rightFace, isInt, &edge2, &edgeleft2);	}	isInt = FALSE;    }    if (!spanData)    {    	points = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec) * pGC->lineWidth);    	if (!points)	    return;    	widths = (int *)ALLOCATE_LOCAL(sizeof(int) * pGC->lineWidth);    	if (!widths)    	{	    DEALLOCATE_LOCAL(points);	    return;    	}    	oldPixel = pGC->fgPixel;    	if (pixel != oldPixel)    	{	    DoChangeGC(pGC, GCForeground, (XID *)&pixel, FALSE);	    ValidateGC (pDraw, pGC);    	}    }    else    {	points = (DDXPointPtr) xalloc (pGC->lineWidth * sizeof (DDXPointRec));	if (!points)	    return;	widths = (int *) xalloc (pGC->lineWidth * sizeof (int));	if (!widths)	{	    xfree (points);	    return;	}	spanRec.points = points;	spanRec.widths = widths;    }    if (isInt)	n = miLineArcI(pDraw, pGC, xorgi, yorgi, points, widths);    else	n = miLineArcD(pDraw, pGC, xorg, yorg, points, widths,		       &edge1, edgey1, edgeleft1,		       &edge2, edgey2, edgeleft2);    if (!spanData)    {    	(*pGC->ops->FillSpans)(pDraw, pGC, n, points, widths, TRUE);    	DEALLOCATE_LOCAL(widths);    	DEALLOCATE_LOCAL(points);    	if (pixel != oldPixel)    	{	    DoChangeGC(pGC, GCForeground, &oldPixel, FALSE);	    ValidateGC (pDraw, pGC);    	}    }    else    {	spanRec.count = n;	AppendSpanGroup (pGC, pixel, &spanRec, spanData)    }}voidmiLineProjectingCap (pDrawable, pGC, pixel, spanData, face, isLeft, xorg, yorg, isInt)    DrawablePtr	    pDrawable;    register GCPtr  pGC;    unsigned long   pixel;    SpanDataPtr	    spanData;    register LineFacePtr face;    Bool	    isLeft;    double	    xorg, yorg;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -