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

📄 zect0.c

📁 nucleus 文件系统,内核和彩色图形系统,在小系统上非常好用
💻 C
字号:
/*************************************************************************/
/*                                                                       */
/*         Copyright (c) 1997 - 1999 Accelerated Technology, Inc.        */
/*                                                                       */
/* PROPRIETARY RIGHTS of Accelerated Technology are involved in the      */
/* subject matter of this material.  All manufacturing, reproduction,    */
/* use, and sales rights pertaining to this subject matter are governed  */
/* by the license agreement.  The recipient of this software implicitly  */
/* accepts the terms of the license.                                     */
/*                                                                       */
/*************************************************************************/

/*************************************************************************/
/*                                                                       */
/* FILE NAME                                            VERSION          */
/*                                                                       */
/*      ZECT0.c                                          1.9             */
/*                                                                       */
/* COMPONENT                                                             */
/*                                                                       */
/*      All                                                              */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This file contains the SetRect and DupRect functions.	         */
/*                                                                       */
/* AUTHOR                                                                */
/*                                                                       */
/*      Giac Dinh, Accelerated Technology, Inc.                          */
/*                                                                       */
/* DATA STRUCTURES                                                       */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* FUNCTIONS                                                             */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* DEPENDENCIES                                                          */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* HISTORY                                                               */
/*                                                                       */
/*         NAME            DATE                    REMARKS               */
/*                                                                       */
/*                                                                       */
/*************************************************************************/

#include "meta_wnd.h"
#include "metconst.h"    /* MetaWINDOW Constant & Stucture Definitions */
#include "metports.h"    /* MetaWINDOW Port & Bitmap Definitions */
#include "grafdata.h"
#include "metmacs3.h"


/* Function SETRECT stores the specified X1,Y1,X2,Y2 coordinates into the
   specified rectangle R.  */

void SetRect ( rect * R , short X1, short Y1, short X2, short Y2)

{
	short TemPt ;
	short ErrValue ;

	if ( X2 < X1 )
	{
		TemPt = X1;
		X1  = X2;
		X2  = TemPt;
	}

#ifdef ErrChecks
/* Error Checking to make sure that Xmin and Xmax are properly assigned  */
	
	if ( (X2 - X1) > 32767)	/* check for overflow condition */
	{
		/* Notify the Error with conditional flag     */
		ErrValue = c_SetRect + c_OfloRect;
		nuGrafErr(ErrValue);
		
		TemPt = ((X2 + X1) >> 1);	/* get mid point */
		X2 = TemPt + 16383;		/* assign Min and Max value */
		X1 = TemPt - 16383;		/* for X coordination       */	
	}
#endif 

	if ( Y2 < Y1 )
	{
		TemPt = Y1 ;			/* Swap points     */
		Y1  = Y2 ;
		Y2  = TemPt;
	}

#ifdef ErrChecks
/* Error Checking to make sure that Ymin and Ymax are properly assigned  */
		
	if ( (Y2 - Y1) > 32767)	/* check for overflow condition */
	{
		/* Notify the Error with conditional flag     */
		ErrValue = c_SetRect + c_OfloRect;
		nuGrafErr(ErrValue);
		
		TemPt = ((Y2 + Y1) >> 1);	/* get mid point */
		Y2 = TemPt + 16383;		/* assign Min and Max value */
		Y1 = TemPt - 16383;		/* for X coordination       */	
	}
#endif 

	R->Xmin = X1;	/* Restore the value back to rect *R       */
	R->Xmax = X2;   /* after calculation                       */
	R->Ymin = Y1;
	R->Ymax = Y2;
		
	return ;
}


/* Function DupRect copies the contents of the source rectangle, srcR, to the
   destination rectangle, dstR.*/

void DupRect ( rect * srcR , rect * dstR )
{

	short ErrValue ;
	short TemPt ;

#ifdef ErrChecks

/* Error Checking to make sure that Xmin and Xmax are properly assigned  */
	if ( (srcR->Xmax - srcR->Xmin) > 32767 )
	{
		/* Notified the Error with conditional flag     */
		ErrValue = c_DupRect + c_OfloRect ;
		nuGrafErr(ErrValue);
		
		TemPt = (srcR->Xmax + srcR->Xmin) >> 1;
		srcR->Xmin = TemPt - 16383 ;			/* Restore calculated value  */
		srcR->Xmax = TemPt +  16383  ;	        /* back into structure       */
	}
	else if ( srcR->Xmax < srcR->Xmin )
	{
		/* Notified the Error with conditional flag     */
		ErrValue = c_DupRect + c_NullRect ;
		nuGrafErr(ErrValue);
		
		TemPt = srcR->Xmin;						/* Swap to make Min and Max  */
		srcR->Xmin = srcR->Xmax ;               /* value properly            */
		srcR->Xmax = TemPt;
	}

/* Error Checking to make sure that Ymin and Ymax are properly assigned  */
	if ( (srcR->Ymax - srcR->Ymin) > 32767 )
	{
		/* Notified the Error with conditional flag     */
		ErrValue = c_DupRect + c_OfloRect ;
		nuGrafErr(ErrValue);
		
		TemPt = (srcR->Ymax + srcR->Ymin) >> 1 ;
		srcR->Ymin = TemPt - 16383 ;			/* Restore calculated value  */
		srcR->Ymax = TemPt + 16383  ;	        /* back into structure       */
	}
	else if ( srcR->Ymax < srcR->Ymin )
	{
		/* Notified the Error with conditional flag     */
		ErrValue = c_DupRect + c_NullRect ;
		nuGrafErr(ErrValue);
		
		TemPt = srcR->Ymin;						/* Swap to make Min and Max  */
		srcR->Ymin = srcR->Ymax ;               /* value properly            */
		srcR->Ymax = TemPt;
	}

#endif

	dstR->Xmin = srcR->Xmin ;		/* Duplicate all value by       */
	dstR->Xmax = srcR->Xmax ;       /* restore them to Destination  */
	dstR->Ymin = srcR->Ymin ;       /* structure                    */
	dstR->Ymax = srcR->Ymax ;

	return ;
}

⌨️ 快捷键说明

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