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

📄 reg18.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          */
/*                                                                       */
/*      REG18.c                                          1.9             */
/*                                                                       */
/* COMPONENT                                                             */
/*                                                                       */
/*      All                                                              */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This file contains the RectInRegion and PtInRegion 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 RectInRegion checks to see if a rectangle;
	0 = does not intersect region
	1 = intersects region  */
int RectInRegion( rect *r , region *rgn )
{
	rect temRect;
	short numRects;
	rect *rgnRectPtr;

	if(globalLevel > 0 )
	{
		U2GR(*r, &temRect,0);
	}
	else
	{
		temRect = *r;
	}

/* Global value and do trival check on region bound box */
	
	temRect.Xmax--;
	temRect.Ymax--;

	if( (temRect.Xmax < rgn->rgnRect.Xmin) ||	
	    (temRect.Xmin >= rgn->rgnRect.Xmax) ||
	    (temRect.Ymax < rgn->rgnRect.Ymin) ||
		(temRect.Ymin >= rgn->rgnRect.Ymax)	  )	
		return(0);  /* Not in rect  */

	temRect.Xmax++;
	temRect.Ymax++;

/* Check each rect in region  */
	numRects = (short) (rgn->rgnListEnd - rgn->rgnList);
	rgnRectPtr = rgn->rgnList;

	while (numRects-- >= 0)
	{	
		if((temRect.Ymax >= rgnRectPtr->Ymin) &&
			(temRect.Ymin <= rgnRectPtr->Ymax) &&
			(temRect.Xmax >= rgnRectPtr->Xmin) &&
			(temRect.Xmin <= rgnRectPtr->Xmax)) return(1);

		rgnRectPtr++;
	}

	return(0);
}


/* Function PtInRegion checks to see if a rectangle of size pxwid by pxht
   centered about point pt;
	0 = does not intersect region
	1 = intersects region  */
int PtInRegion( point *pt, region *rgn, int pxwid, int pxht)
{
	rect temRect;
	short value;
/* Set up test rectangle. In order to match the pen, we
   follow the same rectangle fill rules. This means that an 
   even sized pen will ahve the "extra" size at the right
   and maximun sides  */
	
	if(pxwid < 1)
		pxwid = 1;
	if(pxht < 1)
		pxht = 1;
	
	temRect.Xmin = pt->X - (pxwid >> 1);
	temRect.Ymin = pt->Y - (pxht >> 1);
	temRect.Xmax = temRect.Xmin + pxwid;
	temRect.Ymax = temRect.Ymin + pxht;

	value = RectInRegion(&temRect, rgn);

	return(value);
}

⌨️ 快捷键说明

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