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

📄 xypt4.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          */
/*                                                                       */
/*      XYPT4.c                                          1.9             */
/*                                                                       */
/* COMPONENT                                                             */
/*                                                                       */
/*      All                                                              */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This file contains the ScalePt function.    	                 */
/*                                                                       */
/* 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"
#include <stdio.h>


/* Function ScalePt scales the specified point value, by multiplying the X,Y 
coordinates values by the width and height ratios of the two rectangles. */

void ScalePt ( point * PT, rect * srcR, rect * dstR )

{

	long dst_X, src_X;
	long dst_Y, src_Y;
	short ErrValue ;

/* Take the Delta X and add one for odd integer division case          */
/* Error checking also is included for each single case                */
	
#ifdef ErrChecks
	if (dstR->Xmin > dstR->Xmax)					/* under_flow      */
	{
		ErrValue = c_ScalePt + c_NullRect ;
		nuGrafErr(ErrValue );
		return;
	}
#endif 

	dst_X = dstR->Xmax - dstR->Xmin ;				/* over_flow       */

#ifdef ErrChecks
	if ( dst_X > 0x7fff )
	{
		ErrValue = c_ScalePt + c_OfloRect ;
		nuGrafErr(ErrValue );
		return ;
	}
#endif 

	dst_X +=  1 ;    /* destination point      */

	dst_X = PT->X * dst_X ;			

#ifdef ErrChecks
	if (srcR->Xmin > srcR->Xmax)					/* under_flow      */
	{
		ErrValue = c_ScalePt + c_NullRect ;
		nuGrafErr(ErrValue );
		return ;
	}
#endif	

	src_X = srcR->Xmax - srcR->Xmin ;				/* over_flow       */

#ifdef ErrChecks
	if ( src_X > 0x7fff )
	{
		ErrValue = c_ScalePt  + c_OfloRect ;
		nuGrafErr(ErrValue );
		return ;
	}
#endif 

	src_X +=  1 ;    /* source point       */
	
	src_X = PT->X * dst_X / src_X;  /* Multiply width and  height ratio */    
						            /* for the new X coordinate point   */

#ifdef ErrChecks 
	if ( src_X > 0x7fff)
	{
		ErrValue = c_ScalePt  + c_OfloPt ;
		nuGrafErr(ErrValue);
		return ;
	}
#endif

	PT->X = (short) src_X ;



	

/* Take the Delta Y and add one for odd integer division case           */
/* Error checking also is included for each single case                 */
#ifdef ErrChecks
	if (dstR->Ymin > dstR->Ymax)					/* under_flow      */
	{
		ErrValue = c_ScalePt + c_NullRect ;
		nuGrafErr(ErrValue );
		return;
	}
#endif 

	dst_Y = dstR->Ymax - dstR->Ymin ;				/* over_flow       */
#ifdef ErrChecks
	if ( dst_Y > 0x7fff )
	{
		ErrValue = c_ScalePt + c_OfloRect ;
		nuGrafErr(ErrValue );
		return ;
	}
#endif 

	dst_Y +=  1 ;    /* destination point      */

	dst_Y = PT->Y * dst_Y ;			

#ifdef ErrChecks
	if (srcR->Ymin > srcR->Ymax)					/* under_flow      */
	{
		ErrValue = c_ScalePt + c_NullRect ;
		nuGrafErr(ErrValue );
		return ;
	}
#endif	

	src_Y = srcR->Ymax - srcR->Ymin ;				/* over_flow       */

#ifdef ErrChecks
	if ( src_Y > 0x7fff )
	{
		ErrValue = c_ScalePt  + c_OfloRect ;
		nuGrafErr(ErrValue );
		return ;
	}
#endif 

	src_Y +=  1 ;    /* source point       */
	
	src_Y = PT->Y * dst_Y / src_Y;  /* Multiply width and  height ratio */    
						            /* for the new Y coordinate point   */

#ifdef ErrChecks 
	if ( src_Y > 0x7fff)
	{
		ErrValue = c_ScalePt  + c_OfloPt ;
		nuGrafErr(ErrValue);
		return ;
	}
#endif

	PT->Y = (short) src_Y ;

	return;
}

⌨️ 快捷键说明

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