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

📄 gdchart.c

📁 Nessus的应用与漏洞扫描技术的研究
💻 C
📖 第 1 页 / 共 5 页
字号:
		  ExtVolColor[i] = clrallocate( im, GDC_ExtVolColor[i] );		else		  ExtVolColor[i] = VolColor;	  }/*	ArrowDColor    = gdImageColorAllocate( im, 0xFF,    0, 0 );*//*	ArrowUColor    = gdImageColorAllocate( im,    0, 0xFF, 0 );*/	if( GDC_annotation )		AnnoteColor = clrallocate( im, GDC_annotation->color );	/* attempt to import optional background image */	if( GDC_BGImage )		{		FILE	*in = fopen(GDC_BGImage, "rb");		if( !in )			{			; /* Cant load background image, drop it*/			}		else			{			if( (bg_img = gdImageCreateFromGif(in)) != 0 )					/* =*/				{				int	bgxpos = gdImageSX(bg_img)<GIFWIDTH?  GIFWIDTH/2 - gdImageSX(bg_img)/2:  0,					bgypos = gdImageSY(bg_img)<GIFHEIGHT? GIFHEIGHT/2 - gdImageSY(bg_img)/2: 0;				if( gdImageSX(bg_img) > GIFWIDTH ||				/* resize only if too big*/					gdImageSY(bg_img) > GIFHEIGHT )				/*  [and center]*/					{					gdImageCopyResized( im, bg_img,				/* dst, src*/										bgxpos, bgypos,			/* dstX, dstY*/										0, 0,					/* srcX, srcY*/										GIFWIDTH, GIFHEIGHT,	/* dstW, dstH*/										GIFWIDTH, GIFHEIGHT );	/* srcW, srcH*/					}				else											/* just center*/					gdImageCopy( im, bg_img,					/* dst, src*/								 bgxpos, bgypos,				/* dstX, dstY*/								 0, 0,							/* srcX, srcY*/								 GIFWIDTH, GIFHEIGHT );			/* W, H*/				}			fclose(in);			}		}	for( j=0; j<num_sets; ++j )		for( i=0; i<num_points; ++i )			if( GDC_ExtColor )				{				unsigned long	ext_clr = *(GDC_ExtColor+num_points*j+i);				ExtColor I(j,i)            = clrallocate( im, ext_clr );				if( threeD )					ExtColorShd I(j,i)     = clrshdallocate( im, ext_clr );				}			else if( GDC_SetColor )				{				int	set_clr = GDC_SetColor[j];				ExtColor I(j,i)     = clrallocate( im, set_clr );				if( threeD )				 ExtColorShd I(j,i) = clrshdallocate( im, set_clr );				}			else				{				ExtColor I(j,i)     = PlotColor;				if( threeD )				 ExtColorShd I(j,i) = clrshdallocate( im, GDC_PlotColor );				}				if( GDC_transparent_bg )		gdImageColorTransparent( im, BGColor );	if( GDC_title )		{		int	tlen;		int	titlecolor = clrallocate( im, GDC_TitleColor );		cnt_nl( GDC_title, &tlen );		GDCImageStringNL( im,						  &GDC_fontc[GDC_title_size],						  GIFWIDTH/2 - tlen*GDC_fontc[GDC_title_size].w/2,						  0,						  GDC_title,						  titlecolor,						  GDC_JUSTIFY_CENTER );		}	if( GDC_xtitle )		{		int	titlecolor = GDC_XTitleColor==GDC_DFLTCOLOR? 							PlotColor: clrallocate( im, GDC_XTitleColor );		gdImageString( im,					   GDC_fontc[GDC_xtitle_size].f,					   GIFWIDTH/2 - strlen(GDC_xtitle)*GDC_fontc[GDC_xtitle_size].w/2,					   GIFHEIGHT-GDC_fontc[GDC_xtitle_size].h-1,					   (u_char*)GDC_xtitle,					   titlecolor );		}	/* ----- start drawing ----- */	/* ----- backmost first - grid & labels ----- */	if( GDC_grid || GDC_yaxis )		{	/* grid lines & y label(s) */		float	tmp_y = lowest;		int		labelcolor = GDC_YLabelColor==GDC_DFLTCOLOR? 							 LineColor: clrallocate( im, GDC_YLabelColor );		int		label2color = GDC_YLabel2Color==GDC_DFLTCOLOR? 							  VolColor: clrallocate( im, GDC_YLabel2Color );		/* step from lowest to highest puting in labels and grid at interval points */		/* since now "odd" intervals may be requested, try to step starting at 0,   */		/* if lowest < 0 < highest                                                  */		for( i=-1; i<=1; i+=2 )									/* -1, 1*/			{			if( i == -1 ) {	if( lowest >= 0.0 )					/*	all pos plotting*/								continue;							else								tmp_y = MIN( 0, highest );		/*	step down to lowest*/					}			if( i == 1 )   {if( highest <= 0.0 )				/*	all neg plotting*/								continue;							else								tmp_y = MAX( 0, lowest );		/*	step up to highest*/					}#if 0//			if( !(highest > 0 && lowest < 0) )					/* doesn't straddle 0*//*				{*///				if( i == -1 )									/* only do once: normal*//*					continue;*//*				}*//*			else*//*				tmp_y = 0;*/#endif			do	/* while( (tmp_y (+-)= ylbl_interval) < [highest,lowest] )*/				{				int		n, d, w;				char	*price_to_str( float, int*, int*, int*, char* );				char	nmrtr[3+1], dmntr[3+1], whole[8];				char	all_whole = ylbl_interval<1.0? FALSE: TRUE;				char	*ylbl_str = price_to_str( tmp_y,&n,&d,&w,												  do_ylbl_fractions? NULL: GDC_ylabel_fmt );				if( do_ylbl_fractions )					{					sprintf( nmrtr, "%d", n );					sprintf( dmntr, "%d", d );					sprintf( whole, "%d", w );					}				if( GDC_grid )					{					int	x1, x2, y1, y2;					/* int	gridline_clr = tmp_y == 0.0? LineColor: GridColor;*/																		/* tics*/					x1 = PX(0);		y1 = PY(tmp_y);					gdImageLine( im, x1-2, y1, x1, y1, GridColor );					setno = GDC_stack_type==GDC_STACK_DEPTH? num_hlc_sets? num_hlc_sets:																		   num_sets:															 1;			/* backmost*/					x2 = PX(0);		y2 = PY(tmp_y);						/* w/ new setno*/					gdImageLine( im, x1, y1, x2, y2, GridColor );		/* depth for 3Ds*/					gdImageLine( im, x2, y2, PX(num_points-1+(do_bar?2:0)), y2, GridColor );					setno = 0;											/* set back to foremost*/					}				if( GDC_yaxis ) {					if( do_ylbl_fractions )						{						if( w || (!w && !n && !d) )							{							gdImageString( im,										   GDC_fontc[GDC_yaxisfont_size].f,										   PX(0)-2-strlen(whole)*GDC_fontc[GDC_yaxisfont_size].w												  - ( (!all_whole)?														(strlen(nmrtr)*GDC_fontc[GDC_yaxisfont_size-1].w +														 GDC_fontc[GDC_yaxisfont_size].w                 +														 strlen(nmrtr)*GDC_fontc[GDC_yaxisfont_size-1].w) :														1 ),										   PY(tmp_y)-GDC_fontc[GDC_yaxisfont_size].h/2,										 (u_char*)whole,										   labelcolor );							}						if( n )							{							gdImageString( im,										   GDC_fontc[GDC_yaxisfont_size-1].f,										   PX(0)-2-strlen(nmrtr)*GDC_fontc[GDC_yaxisfont_size-1].w												  -GDC_fontc[GDC_yaxisfont_size].w												  -strlen(nmrtr)*GDC_fontc[GDC_yaxisfont_size-1].w + 1,										   PY(tmp_y)-GDC_fontc[GDC_yaxisfont_size].h/2 + 1,										 (u_char*)nmrtr,										   labelcolor );							gdImageString( im,										   GDC_fontc[GDC_yaxisfont_size].f,										   PX(0)-2-GDC_fontc[GDC_yaxisfont_size].w												  -strlen(nmrtr)*GDC_fontc[GDC_yaxisfont_size-1].w,										   PY(tmp_y)-GDC_fontc[GDC_yaxisfont_size].h/2,										  (u_char*)"/",										   labelcolor );							gdImageString( im,										   GDC_fontc[GDC_yaxisfont_size-1].f,										   PX(0)-2-strlen(nmrtr)*GDC_fontc[GDC_yaxisfont_size-1].w - 2,										   PY(tmp_y)-GDC_fontc[GDC_yaxisfont_size].h/2 + 3,										 (u_char*)dmntr,										   labelcolor );							}						}					else						gdImageString( im,									   GDC_fontc[GDC_yaxisfont_size].f,									   PX(0)-2-strlen(ylbl_str)*GDC_fontc[GDC_yaxisfont_size].w,									   PY(tmp_y)-GDC_fontc[GDC_yaxisfont_size].h/2,									  (u_char*)ylbl_str,									   labelcolor );					}				if( do_vol && GDC_yaxis2 )					{					char	vylbl[16];																				/* opposite of PV(y) */					sprintf( vylbl,							 GDC_ylabel2_fmt? GDC_ylabel2_fmt: "%.0f",							 ((float)(PY(tmp_y)+(setno*ydepth_3D)-vyorig))/vyscl );					setno = GDC_stack_type==GDC_STACK_DEPTH? num_hlc_sets? num_hlc_sets:																		   num_sets:															 1; /* backmost*/					gdImageLine( im, PX(num_points-1+(do_bar?2:0)), PY(tmp_y),									 PX(num_points-1+(do_bar?2:0))+3, PY(tmp_y), GridColor );					if( atof(vylbl) == 0.0 )									/* rounding can cause -0 */						strcpy( vylbl, "0" );					gdImageString( im,								   GDC_fontc[GDC_yaxisfont_size].f,								   PX(num_points-1+(do_bar?2:0))+6,								   PY(tmp_y)-GDC_fontc[GDC_yaxisfont_size].h/2,								   (u_char*)vylbl,								   label2color );					setno = 0;					}				}			while( ((i>0) && ((tmp_y += ylbl_interval) < highest)) ||				   ((i<0) && ((tmp_y -= ylbl_interval) > lowest)) );			}		/* catch last (bottom) grid line - specific to an "off" requested interval */		if( GDC_grid && threeD )			{			setno = GDC_stack_type==GDC_STACK_DEPTH? num_hlc_sets? num_hlc_sets:																   num_sets:													 1;			/* backmost*/			gdImageLine( im, PX(0), PY(lowest), PX(num_points-1+(do_bar?2:0)), PY(lowest), GridColor );			setno = 0;											/* set back to foremost*/			}		/* vy axis title */		if( do_vol && GDC_ytitle2 )			{			int	titlecolor = GDC_YTitle2Color==GDC_DFLTCOLOR? 								VolColor: clrallocate( im, GDC_YTitle2Color );			gdImageStringUp( im,							 GDC_fontc[GDC_ytitle_size].f,							 GIFWIDTH-(1+GDC_fontc[GDC_ytitle_size].h),							 strlen(GDC_ytitle2)*GDC_fontc[GDC_ytitle_size].w/2 +								grapheight/2,							 (u_char*)GDC_ytitle2,							 titlecolor );			}		/* y axis title */		if( GDC_yaxis && GDC_ytitle )			{			int	ytit_len = strlen(GDC_ytitle)*GDC_fontc[GDC_ytitle_size].w;			int	titlecolor = GDC_YTitleColor==GDC_DFLTCOLOR? 								PlotColor: clrallocate( im, GDC_YTitleColor );			gdImageStringUp( im,							 GDC_fontc[GDC_ytitle_size].f,							 0,							 GIFHEIGHT/2 + ytit_len/2,							 (u_char*)GDC_ytitle,							 titlecolor );			}		}	/* interviening set grids */	/*  0 < setno < num_sets   non-inclusive, they've already been covered */	if( GDC_grid && threeD )		{		for( setno=(GDC_stack_type==GDC_STACK_DEPTH? num_hlc_sets? num_hlc_sets: num_sets: 1) - 1;			 setno > 0;			 --setno )			{			gdImageLine( im, PX(0), PY(lowest), PX(0), PY(highest), GridColor );			gdImageLine( im, PX(0), PY(lowest), PX(num_points-1+(do_bar?2:0)), PY(lowest), GridColor );			}		setno = 0;		}	if( ( GDC_grid || GDC_0Shelf ) &&							/* line color grid at 0 */		( (lowest < 0.0 && highest > 0.0) ||		  (lowest < 0.0 && highest > 0.0) ) )		{		int	x1, x2, y1, y2;																/* tics*/		x1 = PX(0);		y1 = PY(0);		gdImageLine( im, x1-2, y1, x1, y1, LineColor );		setno = GDC_stack_type==GDC_STACK_DEPTH? num_hlc_sets? num_hlc_sets:															   num_sets:												 1;				/* backmost*/		x2 = PX(0);		y2 = PY(0);								/* w/ new setno*/		gdImageLine( im, x1, y1, x2, y2, LineColor );			/* depth for 3Ds*/		gdImageLine( im, x2, y2, PX(num_points-1+(do_bar?2:0)), y2, LineColor );		setno = 0;												/* set back to foremost*/		}	/* x ticks and xlables */	if( GDC_grid || GDC_xaxis )		{		int		num_xlbls =										/* maximum x lables that'll fit */																/* each xlbl + avg due to num_lf_xlbls */					graphwidth /						( (GDC_xlabel_spacing== (MAXSHORT) ?0:GDC_xlabel_spacing)+GDC_fontc[GDC_xaxisfont_size].h +						  (num_lf_xlbls*(GDC_fontc[GDC_xaxisfont_size].h-1))/num_points );		int		labelcolor = GDC_XLabelColor==GDC_DFLTCOLOR? 							 LineColor: clrallocate( im, GDC_XLabelColor );		for( i=0; i<num_points+(do_bar?2:0); ++i )			if( (i%(1+num_points/num_xlbls) == 0) ||					/* # x labels are regulated*/				(num_xlbls >= num_points)         ||				GDC_xlabel_spacing == (MAXSHORT) )				{				int	xi = do_bar? i-1: i;				if( GDC_grid )					{					int	x1, x2, y1, y2;																		/* tics*/					x1 = PX(i);		y1 = PY(lowest);					gdImageLine( im, x1, y1, x1,  y1+2, GridColor );					setno = GDC_stack_type==GDC_STACK_DEPTH? num_hlc_sets? num_hlc_sets:																		   num_sets:															 1; /* backmost*/					x2 = PX(i);		y2 = PY(lowest);					gdImageLine( im, x1, y1, x2,  y2, GridColor );		/* depth perspective*/					gdImageLine( im, x2, y2, x2,  PY(highest), GridColor );					setno = 0;											/* reset to foremost*/					}				if( !do_bar || (i>0 && xi<num_points) )					if( GDC_xaxis && xlbl && xlbl[xi] && *(xlbl[xi]) )						{						/* waiting for GDCImageStringUpNL() */#define					LBX		GDC_fontc[GDC_xaxisfont_size]						int		xlen = 0;						short	xstrs_num = cnt_nl( xlbl[xi], &xlen );						char	#ifdef USE_ALLOCA								*sub_xlbl=(char*) alloca ((xlen+1) * sizeof (char));#else								sub_xlbl[xlen+1];#endif /* USE_ALLOCA *//*						int		xlbl_strt = -1+ PX((float)i+(float)(do_bar?((float)num_points/(float)num_xlbls):0.0)) - (int)((float)(LBX.h-2)*((float)xstrs_num/2.0));*/						int		xlbl_strt = -1+ PX(i) - (int)((float)(LBX.h-2)*((float)xstrs_num/2.0));						xlen      = -1;						xstrs_num = -1;						j = -1;						do							{							++j;							++xlen;							sub_xlbl[xlen] = xlbl[xi][j];							if( xlbl[xi][j] == '\n' ||								xlbl[xi][j] == '\0' )								{								sub_xlbl[xlen] = '\0';								++xstrs_num;								gdImageStringUp( im,												 LBX.f,												 xlbl_strt + (LBX.h-1)*xstrs_num,												 PY(lowest) + 2 + 1 + LBX.w*xlen,									 (u_char*)sub_xlbl,												 labelcolor );								xlen = -1;								}							} while( xlbl[xi][j] );#undef LBX						}				}		}

⌨️ 快捷键说明

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