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

📄 miwideline.c

📁 linux下电话本所依赖的一些图形库
💻 C
📖 第 1 页 / 共 4 页
字号:
	GDK_GC_FBDATA(pGC)->values.fill == GDK_TILED)    {	bgPixel = fgPixel;    }    l = ((double) GDK_GC_FBDATA(pGC)->values.line_width) / 2.0;    if (dx == 0)    {	L = dy;	rdx = 0;	rdy = l;	if (dy < 0)	{	    L = -dy;	    rdy = -l;	}    }    else if (dy == 0)    {	L = dx;	rdx = l;	rdy = 0;	if (dx < 0)	{	    L = -dx;	    rdx = -l;	}    }    else    {	L = hypot ((double) dx, (double) dy);	r = l / L;	rdx = r * dx;	rdy = r * dy;    }    k = l * L;    LRemain = L;    /* All position comments are relative to a line with dx and dy > 0,     * but the code does not depend on this */    /* top */    slopes[V_TOP].dx = dx;    slopes[V_TOP].dy = dy;    slopes[V_TOP].k = k;    /* right */    slopes[V_RIGHT].dx = -dy;    slopes[V_RIGHT].dy = dx;    slopes[V_RIGHT].k = 0;    /* bottom */    slopes[V_BOTTOM].dx = -dx;    slopes[V_BOTTOM].dy = -dy;    slopes[V_BOTTOM].k = k;    /* left */    slopes[V_LEFT].dx = dy;    slopes[V_LEFT].dy = -dx;    slopes[V_LEFT].k = 0;    /* preload the start coordinates */    vertices[V_RIGHT].x = vertices[V_TOP].x = rdy;    vertices[V_RIGHT].y = vertices[V_TOP].y = -rdx;    vertices[V_BOTTOM].x = vertices[V_LEFT].x = -rdy;    vertices[V_BOTTOM].y = vertices[V_LEFT].y = rdx;    if (projectLeft)    {	vertices[V_TOP].x -= rdx;	vertices[V_TOP].y -= rdy;	vertices[V_LEFT].x -= rdx;	vertices[V_LEFT].y -= rdy;	slopes[V_LEFT].k = rdx * dx + rdy * dy;    }    lcenterx = x1;    lcentery = y1;    if (GDK_GC_FBDATA(pGC)->values.cap_style == GDK_CAP_ROUND)    {	lcapFace.dx = dx;	lcapFace.dy = dy;	lcapFace.x = x1;	lcapFace.y = y1;	rcapFace.dx = -dx;	rcapFace.dy = -dy;	rcapFace.x = x1;	rcapFace.y = y1;    }    while (LRemain > dashRemain)    {	dashDx = (dashRemain * dx) / L;	dashDy = (dashRemain * dy) / L;	rcenterx = lcenterx + dashDx;	rcentery = lcentery + dashDy;	vertices[V_RIGHT].x += dashDx;	vertices[V_RIGHT].y += dashDy;	vertices[V_BOTTOM].x += dashDx;	vertices[V_BOTTOM].y += dashDy;	slopes[V_RIGHT].k = vertices[V_RIGHT].x * dx + vertices[V_RIGHT].y * dy;	if (GDK_GC_FBDATA(pGC)->values.line_style == GDK_LINE_DOUBLE_DASH || !(dashIndex & 1))	{	    if (GDK_GC_FBDATA(pGC)->values.line_style == GDK_LINE_ON_OFF_DASH && 	        GDK_GC_FBDATA(pGC)->values.cap_style == GDK_CAP_PROJECTING)	    {		saveRight = vertices[V_RIGHT];		saveBottom = vertices[V_BOTTOM];		saveK = slopes[V_RIGHT].k;				if (!first)		{		    vertices[V_TOP].x -= rdx;		    vertices[V_TOP].y -= rdy;    		    vertices[V_LEFT].x -= rdx;		    vertices[V_LEFT].y -= rdy;		    slopes[V_LEFT].k = vertices[V_LEFT].x *				       slopes[V_LEFT].dy -				       vertices[V_LEFT].y *				       slopes[V_LEFT].dx;		}				vertices[V_RIGHT].x += rdx;		vertices[V_RIGHT].y += rdy;		vertices[V_BOTTOM].x += rdx;		vertices[V_BOTTOM].y += rdy;		slopes[V_RIGHT].k = vertices[V_RIGHT].x *				   slopes[V_RIGHT].dy -				   vertices[V_RIGHT].y *				   slopes[V_RIGHT].dx;	    }	    y = miPolyBuildPoly (vertices, slopes, 4, x1, y1,			     	 left, right, &nleft, &nright, &h);	    pixel = (dashIndex & 1) ? bgPixel : fgPixel;	    miFillPolyHelper (pDrawable, pGC, &pixel, spanData, y, h, left, right, nleft, nright);	    if (GDK_GC_FBDATA(pGC)->values.line_style == GDK_LINE_ON_OFF_DASH)	    {		switch (GDK_GC_FBDATA(pGC)->values.cap_style)		{		case GDK_CAP_PROJECTING:		    vertices[V_BOTTOM] = saveBottom;		    vertices[V_RIGHT] = saveRight;		    slopes[V_RIGHT].k = saveK;		    break;		case GDK_CAP_ROUND:		    if (!first)		    {		    	if (dx < 0)		    	{		    	    lcapFace.xa = -vertices[V_LEFT].x;		    	    lcapFace.ya = -vertices[V_LEFT].y;			    lcapFace.k = slopes[V_LEFT].k;		    	}		    	else		    	{		    	    lcapFace.xa = vertices[V_TOP].x;		    	    lcapFace.ya = vertices[V_TOP].y;			    lcapFace.k = -slopes[V_LEFT].k;		    	}		    	miLineArc (pDrawable, pGC, &pixel, spanData,			       	   &lcapFace, (LineFacePtr) NULL,			       	   lcenterx, lcentery, FALSE);		    }		    if (dx < 0)		    {		    	rcapFace.xa = vertices[V_BOTTOM].x;		    	rcapFace.ya = vertices[V_BOTTOM].y;			rcapFace.k = slopes[V_RIGHT].k;		    }		    else		    {		    	rcapFace.xa = -vertices[V_RIGHT].x;		    	rcapFace.ya = -vertices[V_RIGHT].y;			rcapFace.k = -slopes[V_RIGHT].k;		    }		    miLineArc (pDrawable, pGC, &pixel, spanData,			       (LineFacePtr) NULL, &rcapFace,			       rcenterx, rcentery, FALSE);		    break;		default:		  break;	    	}	    }	}	LRemain -= dashRemain;	++dashIndex;	if (dashIndex == GDK_GC_FBDATA(pGC)->dash_list_len)	    dashIndex = 0;	dashRemain = pDash[dashIndex];	lcenterx = rcenterx;	lcentery = rcentery;	vertices[V_TOP] = vertices[V_RIGHT];	vertices[V_LEFT] = vertices[V_BOTTOM];	slopes[V_LEFT].k = -slopes[V_RIGHT].k;	first = FALSE;    }    if (GDK_GC_FBDATA(pGC)->values.line_style == GDK_LINE_DOUBLE_DASH || !(dashIndex & 1))    {    	vertices[V_TOP].x -= dx;    	vertices[V_TOP].y -= dy;	vertices[V_LEFT].x -= dx;	vertices[V_LEFT].y -= dy;	vertices[V_RIGHT].x = rdy;	vertices[V_RIGHT].y = -rdx;	vertices[V_BOTTOM].x = -rdy;	vertices[V_BOTTOM].y = rdx;		if (projectRight)	{	    vertices[V_RIGHT].x += rdx;	    vertices[V_RIGHT].y += rdy;    	    vertices[V_BOTTOM].x += rdx;	    vertices[V_BOTTOM].y += rdy;	    slopes[V_RIGHT].k = vertices[V_RIGHT].x *				slopes[V_RIGHT].dy -				vertices[V_RIGHT].y *				slopes[V_RIGHT].dx;	}	else	    slopes[V_RIGHT].k = 0;	if (!first && GDK_GC_FBDATA(pGC)->values.line_style == GDK_LINE_ON_OFF_DASH &&	    GDK_GC_FBDATA(pGC)->values.cap_style == GDK_CAP_PROJECTING)	{	    vertices[V_TOP].x -= rdx;	    vertices[V_TOP].y -= rdy;	    vertices[V_LEFT].x -= rdx;	    vertices[V_LEFT].y -= rdy;	    slopes[V_LEFT].k = vertices[V_LEFT].x *			       slopes[V_LEFT].dy -			       vertices[V_LEFT].y *			       slopes[V_LEFT].dx;	}	else	    slopes[V_LEFT].k += dx * dx + dy * dy;	y = miPolyBuildPoly (vertices, slopes, 4, x2, y2,			     left, right, &nleft, &nright, &h);	pixel = (dashIndex & 1) ? GDK_GC_FBDATA(pGC)->values.background : GDK_GC_FBDATA(pGC)->values.foreground;	miFillPolyHelper (pDrawable, pGC, &pixel, spanData, y, h, left, right, nleft, nright);	if (!first && GDK_GC_FBDATA(pGC)->values.line_style == GDK_LINE_ON_OFF_DASH &&	    GDK_GC_FBDATA(pGC)->values.cap_style == GDK_CAP_ROUND)	{	    lcapFace.x = x2;	    lcapFace.y = y2;	    if (dx < 0)	    {		lcapFace.xa = -vertices[V_LEFT].x;		lcapFace.ya = -vertices[V_LEFT].y;		lcapFace.k = slopes[V_LEFT].k;	    }	    else	    {		lcapFace.xa = vertices[V_TOP].x;		lcapFace.ya = vertices[V_TOP].y;		lcapFace.k = -slopes[V_LEFT].k;	    }	    miLineArc (pDrawable, pGC, &pixel, spanData,		       &lcapFace, (LineFacePtr) NULL,		       rcenterx, rcentery, FALSE);	}    }    dashRemain = ((double) dashRemain) - LRemain;    if (dashRemain == 0)    {	dashIndex++;	if (dashIndex == GDK_GC_FBDATA(pGC)->dash_list_len)	    dashIndex = 0;	dashRemain = pDash[dashIndex];    }    leftFace->x = x1;    leftFace->y = y1;    leftFace->dx = dx;    leftFace->dy = dy;    leftFace->xa = rdy;    leftFace->ya = -rdx;    leftFace->k = k;    rightFace->x = x2;    rightFace->y = y2;    rightFace->dx = -dx;    rightFace->dy = -dy;    rightFace->xa = -rdy;    rightFace->ya = rdx;    rightFace->k = k;    *pDashIndex = dashIndex;    *pDashOffset = pDash[dashIndex] - dashRemain;}voidmiWideDash (GdkDrawable *pDrawable, register GdkGC *pGC, int mode,            register int npt, register GdkPoint *pPts){    int		    x1, y1, x2, y2;    GdkColor pixel;    gboolean	    projectLeft, projectRight;    LineFaceRec	    leftFace, rightFace, prevRightFace;    LineFaceRec	    firstFace;    int		    first;    int		    dashIndex, dashOffset;    register int    prevDashIndex;    SpanDataRec	    spanDataRec;    SpanDataPtr	    spanData;    gboolean	    somethingDrawn = FALSE;    gboolean	    selfJoin;    gboolean	    endIsFg = FALSE, startIsFg = FALSE;    gboolean            firstIsFg = FALSE, prevIsFg = FALSE;#ifndef XFree86Server    /* XXX backward compatibility */    if (GDK_GC_FBDATA(pGC)->values.line_width == 0)    {	miZeroDashLine (pDrawable, pGC, mode, npt, pPts);	return;    }#endif    if (GDK_GC_FBDATA(pGC)->values.line_style == GDK_LINE_DOUBLE_DASH && 	(GDK_GC_FBDATA(pGC)->values.fill == GDK_OPAQUE_STIPPLED || GDK_GC_FBDATA(pGC)->values.fill == GDK_TILED))    {	miWideLine (pDrawable, pGC, mode, npt, pPts);	return;    }    if (npt == 0)	return;    spanData = miSetupSpanData (pGC, &spanDataRec, npt);    x2 = pPts->x;    y2 = pPts->y;    first = TRUE;    selfJoin = FALSE;    if (0 /* mode == CoordModePrevious */)    {	int nptTmp;	GdkPoint* pPtsTmp;	x1 = x2;	y1 = y2;	nptTmp = npt;	pPtsTmp = pPts + 1;	while (--nptTmp)	{	    x1 += pPtsTmp->x;	    y1 += pPtsTmp->y;	    ++pPtsTmp;	}	if (x2 == x1 && y2 == y1)	    selfJoin = TRUE;    }    else if (x2 == pPts[npt-1].x && y2 == pPts[npt-1].y)    {	selfJoin = TRUE;    }    projectLeft = GDK_GC_FBDATA(pGC)->values.cap_style == GDK_CAP_PROJECTING && !selfJoin;    projectRight = FALSE;    dashIndex = 0;    dashOffset = 0;    miStepDash (GDK_GC_FBDATA(pGC)->dash_offset, &dashIndex,	        GDK_GC_FBDATA(pGC)->dash_list, (int)GDK_GC_FBDATA(pGC)->dash_list_len, &dashOffset);    while (--npt)    {	x1 = x2;	y1 = y2;	++pPts;	x2 = pPts->x;	y2 = pPts->y;	if (0 /* mode == CoordModePrevious */)	{	    x2 += x1;	    y2 += y1;	}	if (x1 != x2 || y1 != y2)	{	    somethingDrawn = TRUE;	    if (npt == 1 && GDK_GC_FBDATA(pGC)->values.cap_style == GDK_CAP_PROJECTING && 		(!selfJoin || !firstIsFg))		projectRight = TRUE;	    prevDashIndex = dashIndex;	    miWideDashSegment (pDrawable, pGC, spanData, &dashOffset, &dashIndex,				x1, y1, x2, y2,				projectLeft, projectRight, &leftFace, &rightFace);	    startIsFg = !(prevDashIndex & 1);	    endIsFg = (dashIndex & 1) ^ (dashOffset != 0);	    if (GDK_GC_FBDATA(pGC)->values.line_style == GDK_LINE_DOUBLE_DASH || startIsFg)	    {	    	pixel = startIsFg ? GDK_GC_FBDATA(pGC)->values.foreground : GDK_GC_FBDATA(pGC)->values.background;	    	if (first || (GDK_GC_FBDATA(pGC)->values.line_style == GDK_LINE_ON_OFF_DASH && !prevIsFg))	    	{	    	    if (first && selfJoin)		    {		    	firstFace = leftFace;			firstIsFg = startIsFg;		    }	    	    else if (GDK_GC_FBDATA(pGC)->values.cap_style == GDK_CAP_ROUND)		    	miLineArc (pDrawable, pGC, &pixel, spanData,			       	   &leftFace, (LineFacePtr) NULL,			       	   (double)0.0, (double)0.0, TRUE);	    	}	    	else	    	{	    	    miLineJoin (pDrawable, pGC, &pixel, spanData, &leftFace,		            	&prevRightFace);	    	}	    }	    prevRightFace = rightFace;	    prevIsFg = endIsFg;	    first = FALSE;	    projectLeft = FALSE;	}	if (npt == 1 && somethingDrawn)	{	    if (GDK_GC_FBDATA(pGC)->values.line_style == GDK_LINE_DOUBLE_DASH || endIsFg)	    {		pixel = endIsFg ? GDK_GC_FBDATA(pGC)->values.foreground : GDK_GC_FBDATA(pGC)->values.background;		if (selfJoin && (GDK_GC_FBDATA(pGC)->values.line_style == GDK_LINE_DOUBLE_DASH || firstIsFg))		{		    miLineJoin (pDrawable, pGC, &pixel, spanData, &firstFace,				&rightFace);		}		else 		{		    if (GDK_GC_FBDATA(pGC)->values.cap_style == GDK_CAP_ROUND)			miLineArc (pDrawable, pGC, &pixel, spanData,				    (LineFacePtr) NULL, &rightFace,				    (double)0.0, (double)0.0, TRUE);		}	    }	    else	    {		/* glue a cap to the start of the line if		 * we're OnOffDash and ended on odd dash		 */		if (selfJoin && firstIsFg)		{		    pixel = GDK_GC_FBDATA(pGC)->values.foreground;		    if (GDK_GC_FBDATA(pGC)->values.cap_style == GDK_CAP_PROJECTING)			miLineProjectingCap (pDrawable, pGC, &pixel, spanData,				    &firstFace, TRUE,				    (double)0.0, (double)0.0, TRUE);		    else if (GDK_GC_FBDATA(pGC)->values.cap_style == GDK_CAP_ROUND)			miLineArc (pDrawable, pGC, &pixel, spanData,				    &firstFace, (LineFacePtr) NULL,				    (double)0.0, (double)0.0, TRUE);		}	    }	}    }    /* handle crock where all points are coincident */    if (!somethingDrawn && (GDK_GC_FBDATA(pGC)->values.line_style == GDK_LINE_DOUBLE_DASH || !(dashIndex & 1)))    {	/* not the same as endIsFg computation above */	pixel = (dashIndex & 1) ? GDK_GC_FBDATA(pGC)->values.background : GDK_GC_FBDATA(pGC)->values.foreground;	switch (GDK_GC_FBDATA(pGC)->values.cap_style) {	case GDK_CAP_ROUND:	    miLineArc (pDrawable, pGC, &pixel, spanData,		       (LineFacePtr) NULL, (LineFacePtr) NULL,		       (double)x2, (double)y2,		       FALSE);	    break;	case GDK_CAP_PROJECTING:	    x1 = GDK_GC_FBDATA(pGC)->values.line_width;	    miFillRectPolyHelper (pDrawable, pGC, &pixel, spanData,				  x2 - (x1 >> 1), y2 - (x1 >> 1), x1, x1);	    break;	default:	  break;	}    }    if (spanData)	miCleanupSpanData (pDrawable, pGC, spanData);}/* these are stubs to allow old ddx miValidateGCs to work without change */voidmiMiter(void){}voidmiNotMiter(void){}

⌨️ 快捷键说明

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