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

📄 grdevsub.c

📁 一个很好的分子动力学程序
💻 C
📖 第 1 页 / 共 2 页
字号:
/*************************************************************************Exported Functions*************************************************************************/								  /*	 "ROUTING" ROUTINES  */void grdev_initfile (void){	if (PSflag)		PS_InitFile();	else		Canon_InitFile();}void grdev_drawto (float x, float y){	if (PSflag)		PS_DrawTo (x, y);	else		Canon_DrawTo (x,y);}void grdev_drawrel (float dx, float dy){	if (PSflag)		PS_DrawRel (dx,dy);	else		Canon_DrawRel (dx,dy);}void grdev_drawpoly (int npoly, polytype *poly){	if (PSflag)		PS_Drawpoly (npoly, poly);	else		Canon_Drawpoly (npoly, poly);}void grdev_writetext (char *instr){	int i, flag;	/*  REMOVE TRAILING \n	*/	i = strlen(instr);	while (i && instr[i]!='\n')		i--;	flag = (instr[i]=='\n');	if (flag)		instr[i] = 0;	/*  PRINT STRING	*/	if (PSflag)		PS_WriteText (instr);	else		Canon_WriteText (instr);	/*  RESTORE \n  */	if (flag)		instr[i] = '\n';}void grdev_circle (float radius){	if (PSflag)		PS_Circle (radius);	else		Canon_Circle (radius);}void grdev_writepage (void){	if (PSflag)		PS_WritePage ();	else		Canon_WritePage();}void grdev_setrgbcolor (BYTE Red, BYTE Green, BYTE Blue, BOOLEAN ForceChange)	{	static int   LastRed   = 0;	static int   LastGreen = 0;	static int   LastBlue  = 0;	static float Factor    = 1.0 / 255.0;	/*  Return  if device doesnot support color  */	if (!PSflag)		return;	/*  Color  doesn't change  - ignore  */	if 	(	!ForceChange &&	LastRed   == Red   &&	LastGreen == Green &&	LastBlue  == Blue 	)		return;		/*  Set new color  */	PS_setrgbcolor (Factor*Red, Factor*Green, Factor*Blue);	/*  Record color  */	LastRed   = Red;	LastGreen = Green;	LastBlue  = Blue;	}	void grdev_sethsbcolor (BYTE Hue, BYTE Saturation, BYTE Brightness, BOOLEAN  ForceChange)	{	static int   LastHue   = 0;	static int   LastSaturation = 0;	static int   LastBrightness = 1;	static float Factor    = 1.0 / 255.0;	/*  Return  if device doesnot support color  */	if (!PSflag)		return;	/*  Color  doesn't change  - ignore  */	if 	(	!ForceChange &&	LastHue   == Hue   &&	LastSaturation == Saturation &&	LastBrightness == Brightness 	)		return;		/*  Set new color  */	PS_sethsbcolor (Factor*Hue, Factor*Saturation, Factor*Brightness);	/*  Record color  */	LastHue   = Hue;	LastSaturation = Saturation;	LastBrightness = Brightness;	}	void grdev_setcmybcolor (BYTE Cyan, BYTE Magenta, BYTE Yellow, BYTE Black, BOOLEAN ForceChange)	{	static int   LastCyan  = 0;	static int   LastMagenta = 0;	static int   LastYellow = 0;	static int   LastBlack  = 1;	static float Factor    = 1.0 / 255.0;	/*  Return  if device doesnot support color  */	if (!PSflag)		return;	/*  Color  doesn't change  - ignore  */	if 	(	!ForceChange &&	LastCyan == Cyan &&	LastMagenta == Magenta &&	LastYellow == Yellow &&	LastBlack == Black	)		return;		/*  Set new color  */	PS_setcmybcolor (Factor*Cyan, Factor*Magenta, Factor*Yellow, Factor*Black);	/*  Record color  */	LastCyan = Cyan;	LastMagenta = Magenta;	LastYellow = Yellow;	LastBlack = Black;	}void grdev_setcolor(ColorModel_t ColorModel, ColorTable_t ColorTable)	{	static ColorModel_t LastColorModel  = COLOR_RGB;	static ColorTable_t LastColorTable  = {0, 0, 0, 0};	BOOLEAN ColorModelChange;	int    icolor;	/*  If color  hasn't changed  from last time, ignore this call   */	if (LastColorModel == ColorModel)		{		/*  Test RGB  color model  */		if 		(		(LastColorModel==COLOR_RGB || LastColorModel==COLOR_HSB) &&		LastColorTable[0]==ColorTable[0] &&		LastColorTable[1]==ColorTable[1] &&		LastColorTable[2]==ColorTable[2] 		)			return;		/*  Test  CMYB color model  */		if 		(		LastColorModel==COLOR_CMYB &&		LastColorTable[0]==ColorTable[0] &&		LastColorTable[1]==ColorTable[1] &&		LastColorTable[2]==ColorTable[2] &&		LastColorTable[3]==ColorTable[3] 		)			return;				}		 	/*  Call correct color model routine  */	ColorModelChange = (LastColorModel!=ColorModel);	if (ColorModel==COLOR_RGB)		grdev_setrgbcolor 			(ColorTable[0], ColorTable[1], ColorTable[2], ColorModelChange);	else if (ColorModel==COLOR_HSB)		grdev_sethsbcolor 			(ColorTable[0], ColorTable[1], ColorTable[2], ColorModelChange);	else  if (ColorModel==COLOR_CMYB)		grdev_setcmybcolor 			(ColorTable[0], ColorTable[1], ColorTable[2], ColorTable[3], ColorModelChange);	/*  Store  current color setting   */	LastColorModel = ColorModel;	for (icolor=0; icolor<NCMYB; ++icolor)		LastColorTable[icolor] = ColorTable[icolor];			}							/*  DEVICE INDEPENDENT ROUTINES	*/void grdev_init (void){	/*  DEVICE SPECIFIC COMMANDS	*/	/*  INITALIZE VARIABLES 		*/	fillflag = 0;	curx		= 0;	cury		= 0;	textsize = 1.0/6.0;	settextflag = 1;}void grdev_assignfile (FILE *fin){	__f = fin;}void grdev_canon (void){	PSflag = 0;}void grdev_ps (void){	PSflag = 1;}void grdev_moveto (float x, float y){	curx = x;	cury = y;}void grdev_moverel(float dx, float dy){	curx = curx + dx;	cury = cury + dy;}void grdev_setfill (int flag){	fillflag = flag;}void grdev_settextsize (float size){	textsize = size;	settextflag = 1;}float grdev_gettextsize (void){	return(textsize);}void grdev_triangle	 (float radius){	temppoly[0].x = 0.0;	temppoly[0].y = radius;	temppoly[1].x =  0.5*sqrt(3)*radius;	temppoly[1].y = -1.5 		 *radius;	temppoly[2].x =	  -sqrt(3)*radius;	temppoly[2].y =  0.0;	grdev_drawpoly (3, temppoly);}void grdev_itriangle  (float radius ){	temppoly[0].x =  0.0;	temppoly[0].y = -radius;	temppoly[1].x =  0.5*sqrt(3)*radius;	temppoly[1].y =  1.5 		 *radius;	temppoly[2].x =	  -sqrt(3)*radius;	temppoly[2].y =  0.0;	grdev_drawpoly (3, temppoly);	grdev_drawpoly (3, temppoly);}void grdev_diamond	 (float radius ){	temppoly[0].x =  0.0;	temppoly[0].y =  radius;	temppoly[1].x =  radius;	temppoly[1].y = -radius;	temppoly[2].x = -radius;	temppoly[2].y = -radius;	temppoly[3].x = -radius;	temppoly[3].y =  radius;	grdev_drawpoly (4, temppoly);}void grdev_cross (float radius){	grdev_moverel (  0,		  -radius);	grdev_drawrel (  0,		 2*radius);	grdev_moverel ( -radius,  -radius);	grdev_drawrel (2*radius,	0		);	grdev_moverel ( -radius,	0		);}void grdev_square 	 (float radius ){	radius = radius / sqrt(2);	temppoly[0].x =  radius;	temppoly[0].y =  radius;	temppoly[1].x =  0;	temppoly[1].y = -2*radius;	temppoly[2].x = -2*radius;	temppoly[2].y =  0;	temppoly[3].x =  0;	temppoly[3].y = 2*radius;	grdev_drawpoly (4, temppoly);}void grdev_asterisk	 (float radius ){	float dx,dy, xcen,ycen;	xcen = curx;	ycen = cury;	dx   = 0.5*sqrt(3)*radius;	dy   = 0.5			*radius;	/*  DRAW VERTICAL ARM  */	grdev_moverel (0, radius);	grdev_drawrel (0, -2*radius);	grdev_moveto  (xcen, ycen);	/*  DRAW LEFT ARM  */	grdev_moverel (dx, dy);	grdev_drawrel (-2*dx, -2*dy);	grdev_moveto  (xcen, ycen);	/*  DRAW RIGHT ARM  */	grdev_moverel (-dx, dy);	grdev_drawrel (2*dx, -2*dy);	grdev_moveto  (xcen, ycen);}void grdev_printf (char *format, ...){	char cbuffer[1024];	va_list argptr;	/*  CONVERT ARGUMENTS TO STRING	*/	va_start (argptr, format);	vsprintf (cbuffer, format, argptr);	va_end	(argptr);	/*  CALL WRITE TEXT	*/	grdev_writetext (cbuffer);}

⌨️ 快捷键说明

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