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

📄 svg.c

📁 下载来的一个看图软件的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
	return (svg_named_color[i_best].name);}static void svg_style_fill (wmfAPI* API,wmfDC* dc){	wmf_svg_t* ddata = WMF_SVG_GetData (API);	wmfRGB* bg_color;	wmfRGB* brush_color;	wmfBMP* brush_bmp;	wmfBrush* brush;	unsigned int fill_opaque;	unsigned int fill_polyfill;	unsigned int fill_ROP;	unsigned int brush_style;	unsigned int brush_hatch;	wmfStream* out = ddata->out;	WMF_DEBUG (API,"~~~~~~~~svg_style_fill");	if (out == 0) return;	fill_opaque   = (unsigned int) WMF_DC_OPAQUE (dc);	fill_polyfill = (unsigned int) WMF_DC_POLYFILL (dc);	fill_ROP      = (unsigned int) WMF_DC_ROP (dc);	bg_color = WMF_DC_BACKGROUND (dc);	brush = WMF_DC_BRUSH (dc);	brush_style = (unsigned int) WMF_BRUSH_STYLE (brush);	brush_hatch = (unsigned int) WMF_BRUSH_HATCH (brush);	brush_color = WMF_BRUSH_COLOR (brush);	brush_bmp = WMF_BRUSH_BITMAP (brush);	if (brush_style == BS_NULL)	{	wmf_stream_printf (API,out,"fill:none");		return;	}	if (fill_opaque)	{	wmf_stream_printf (API,out,"fill-opacity:1.0; ");	}	else	{	wmf_stream_printf (API,out,"fill-opacity:0.5; "); /* semi-transparent... ?? */	}	switch (fill_polyfill) /* Is this correct ?? */	{	case WINDING:		wmf_stream_printf (API,out,"fill-rule:nonzero; ");	break;	case ALTERNATE:	default:		wmf_stream_printf (API,out,"fill-rule:evenodd; ");	break;	}	switch (brush_style)	{#ifdef WRITE_EPS_NOT_SVG/*	float side; */	case BS_HATCHED:		fputs ("clip ",out);		if (dc->bgmode != TRANSPARENT)		{	rgb = dc->bgcolor;			red   = (float) ((int) rgb.r) / 255;			green = (float) ((int) rgb.g) / 255;			blue  = (float) ((int) rgb.b) / 255;			fprintf (out,"%f %f %f setrgbcolor ",red,green,blue);			fputs ("fill ",out);		}		fputs ("\n",out);		fputs ("1 setlinewidth ",out);		fputs ("[] 0 setdash ",out);		rgb = brush->lbColor;		red   = (float) ((int) rgb.r) / 255;		green = (float) ((int) rgb.g) / 255;		blue  = (float) ((int) rgb.b) / 255;		fprintf (out,"%f %f %f setrgbcolor\n",red,green,blue);		switch (brush->lbHatch)		{		case HS_HORIZONTAL:			fprintf (out,"%f 5 %f { newpath dup %f exch moveto %f exch lineto stroke } for\n",			         bbox->TL.y,bbox->BR.y,bbox->TL.x,bbox->BR.x);		break;		case HS_VERTICAL:			fprintf (out,"%f 5 %f { newpath dup %f moveto %f lineto stroke } for\n",			         bbox->TL.x,bbox->BR.x,bbox->TL.y,bbox->BR.y);		break;		case HS_FDIAGONAL:			fputs ("gsave % HS_FDIAGONAL\n",out);			fprintf (out,"%f %f translate -45 rotate ",			         bbox->TL.x-(bbox->BR.y-bbox->TL.y)/2,(bbox->TL.y+bbox->BR.y)/2);			side = ((bbox->BR.x-bbox->TL.x) + (bbox->BR.y-bbox->TL.y)) / 1.41421356237309504880;			fprintf (out,"0 5 %f { newpath dup 0 moveto %f lineto stroke } for ",			         side,side);			fputs ("grestore\n",out);		break;		case HS_BDIAGONAL:			fputs ("gsave % HS_BDIAGONAL\n",out);			fprintf (out,"%f %f translate -45 rotate ",			         bbox->TL.x-(bbox->BR.y-bbox->TL.y)/2,(bbox->TL.y+bbox->BR.y)/2);			side = ((bbox->BR.x-bbox->TL.x) + (bbox->BR.y-bbox->TL.y)) / 1.41421356237309504880;			fprintf (out,"0 5 %f { newpath dup 0 exch moveto %f exch lineto stroke } for ",			         side,side);			fputs ("grestore\n",out);		break;		case HS_CROSS:			fprintf (out,"%f 5 %f { newpath dup %f exch moveto %f exch lineto stroke } for\n",			         bbox->TL.y,bbox->BR.y,bbox->TL.x,bbox->BR.x);			fprintf (out,"%f 5 %f { newpath dup %f moveto %f lineto stroke } for\n",			         bbox->TL.x,bbox->BR.x,bbox->TL.y,bbox->BR.y);		break;		case HS_DIAGCROSS:			fputs ("gsave % HS_DIAGCROSS\n",out);			fprintf (out,"%f %f translate -45 rotate ",			         bbox->TL.x-(bbox->BR.y-bbox->TL.y)/2,(bbox->TL.y+bbox->BR.y)/2);			side = ((bbox->BR.x-bbox->TL.x) + (bbox->BR.y-bbox->TL.y)) / 1.41421356237309504880;			fprintf (out,"0 5 %f { newpath dup 0 moveto %f lineto stroke } for ",			         side,side);			fprintf (out,"0 5 %f { newpath dup 0 exch moveto %f exch lineto stroke } for ",			         side,side);			fputs ("grestore\n",out);		break;		default:			if (API->flags & WMF_OPT_IGNORE_NONFATAL)			{	WMF_DEBUG (API,"Unsupported brush/hatch style!");			}			else			{	WMF_ERROR (API,"Unsupported brush/hatch style!");				API->err = wmf_E_Glitch;			}		break;		}	break;#endif /* WRITE_EPS_NOT_SVG */	case BS_DIBPATTERN:		if (brush_bmp->data == 0)		{	if (API->flags & WMF_OPT_IGNORE_NONFATAL)			{	WMF_DEBUG (API,"Attempt to fill with non-existent pattern!");			}			else			{	WMF_ERROR (API,"Attempt to fill with non-existent pattern!");				API->err = wmf_E_Glitch;				break;			}		}		/* no break here - TODO: implement bitmap fill */	default:		if (API->flags & WMF_OPT_IGNORE_NONFATAL)		{	WMF_DEBUG (API,"Unsupported brush style!");			/* no break here */		}		else		{	WMF_ERROR (API,"Unsupported brush style!");			API->err = wmf_E_Glitch;			break;		}	case BS_SOLID:	break;	}	wmf_stream_printf (API,out,"fill:%s",svg_color_closest (brush_color));}static void svg_style_stroke (wmfAPI* API,wmfDC* dc){	wmf_svg_t* ddata = WMF_SVG_GetData (API);	wmfPen* pen;	wmfRGB* pen_color;	float pen_width;	unsigned int pen_style;	unsigned int pen_endcap;	unsigned int pen_join;	unsigned int pen_type;	wmfStream* out = ddata->out;	WMF_DEBUG (API,"~~~~~~~~svg_style_stroke");	if (out == 0) return;	pen = WMF_DC_PEN (dc);	pen_color = WMF_PEN_COLOR (pen);	pen_width = ( svg_width  (API,(float) WMF_PEN_WIDTH  (pen))	            + svg_height (API,(float) WMF_PEN_HEIGHT (pen)) ) / 2;	pen_style  = (unsigned int) WMF_PEN_STYLE (pen);	pen_endcap = (unsigned int) WMF_PEN_ENDCAP (pen);	pen_join   = (unsigned int) WMF_PEN_JOIN (pen);	pen_type   = (unsigned int) WMF_PEN_TYPE (pen);	if (pen_style == PS_NULL)	{	wmf_stream_printf (API,out,"stroke:none");		return;	}	wmf_stream_printf (API,out,"stroke-width:%f; ",MAX (0,pen_width));	switch (pen_endcap)	{	case PS_ENDCAP_SQUARE:		wmf_stream_printf (API,out,"stroke-linecap:square; ");	break;	case PS_ENDCAP_ROUND:		wmf_stream_printf (API,out,"stroke-linecap:round; ");	break;	case PS_ENDCAP_FLAT:	default:		wmf_stream_printf (API,out,"stroke-linecap:butt; ");	break;	}	switch (pen_join)	{	case PS_JOIN_BEVEL:		wmf_stream_printf (API,out,"stroke-linejoin:bevel; ");	break;	case PS_JOIN_ROUND:		wmf_stream_printf (API,out,"stroke-linejoin:round; ");	break;	case PS_JOIN_MITER:	default:		wmf_stream_printf (API,out,"stroke-linejoin:miter; ");	break;	}	switch (pen_style)	{	case PS_DASH: /* DASH_LINE */		wmf_stream_printf (API,out,"stroke-dasharray:%f %f; ",		         pen_width*10,pen_width*10);	break;	case PS_ALTERNATE:	case PS_DOT: /* DOTTED_LINE */		wmf_stream_printf (API,out,"stroke-dasharray:%f %f; ",		         pen_width,pen_width*2);	break;	case PS_DASHDOT: /* DASH_DOT_LINE */		wmf_stream_printf (API,out,"stroke-dasharray:%f %f %f %f; ",		         pen_width*10,pen_width*2,pen_width,pen_width*2);	break;	case PS_DASHDOTDOT: /* DASH_2_DOTS_LINE */		wmf_stream_printf (API,out,"stroke-dasharray:%f %f %f %f %f %f; ",		         pen_width*10,pen_width*2,pen_width,pen_width*2,pen_width,pen_width*2);	break;	case PS_INSIDEFRAME: /* There is nothing to do in this case... */	case PS_SOLID:	default:		wmf_stream_printf (API,out,"stroke-dasharray:none; ");	break;	}	wmf_stream_printf (API,out,"stroke:%s",svg_color_closest (pen_color));}#endif /* ! WITHOUT_LAYERS */

⌨️ 快捷键说明

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