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

📄 rect0.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          */
/*                                                                       */
/*      RECT0.c                                          1.9             */
/*                                                                       */
/* COMPONENT                                                             */
/*                                                                       */
/*      All                                                              */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This file contains the FrameRect function.                       */
/*                                                                       */
/* AUTHOR                                                                */
/*                                                                       */
/*      Robert G. Burrill, 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 FrameRect outlines the specified rectangle argVR using the
current RasterOp write mode, pen pattern and pen size. */

void FrameRect(rect *argVR)
{
	rect tempRect;
	struct _lineRcd{
		rect LR;
		short skipStat;
	} lineRcd[4];
	rect R[4];
	short halfWidthLeft;	/* offsets to edges of square pen */
	short halfWidthRight;
	short halfHeightUp;
	short halfHeightDown;
	void (*lineExecPntr)();

	tempRect = *argVR;	/* get rectangle */
	if (globalLevel > 0)
	{
		/* convert from user to global */
		U2GR(tempRect, &tempRect, 1);
	}

	/* what kind of optimization can we do (as vectors or fills)? */

 	if ((grafPort.pnFlags & pnDashFlg) || (!(grafPort.pnFlags & pnSizeFlg)))
	{	/* do vectors since only vectors know how to dash; also fills
		are faster only if wide pen */

		/* setup blitlist and call MultiVect for 4 line segments; use
		skiplast drawing clockwise to avoid double draw of end points */
		lineRcd[0].LR.Xmin = tempRect.Xmin;	/* top */
		lineRcd[0].LR.Ymin = tempRect.Ymin;
		lineRcd[0].LR.Xmax = tempRect.Xmax;
		lineRcd[0].LR.Ymax = tempRect.Ymin;
		lineRcd[0].skipStat = SkipLast;
	      
		lineRcd[1].LR.Xmin = tempRect.Xmax;	/* bottom */
		lineRcd[1].LR.Ymin = tempRect.Ymax;
		lineRcd[1].LR.Xmax = tempRect.Xmin;
		lineRcd[1].LR.Ymax = tempRect.Ymax;
		lineRcd[1].skipStat = SkipLast;

		lineRcd[2].LR.Xmin = tempRect.Xmin;	/* left */
		lineRcd[2].LR.Ymin = tempRect.Ymax;
		lineRcd[2].LR.Xmax = tempRect.Xmin;
		lineRcd[2].LR.Ymax = tempRect.Ymin;
		lineRcd[2].skipStat = SkipLast;

		lineRcd[3].LR.Xmin = tempRect.Xmax;	/* right */
		lineRcd[3].LR.Ymin = tempRect.Ymin;
		lineRcd[3].LR.Xmax = tempRect.Xmax;
		lineRcd[3].LR.Ymax = tempRect.Ymax;
		lineRcd[3].skipStat = SkipLast;

		grafBlit.blitList = (long) &lineRcd[0];	/* set pointer to our blitlist */
		grafBlit.blitCnt = 4;

		lineExecPntr = (void (*)()) lineExecIDV;	/* draw rectangle */
		lineExecPntr(&grafBlit);

		grafBlit.blitList = (long) &grafBlist;	/* restore standard blit list pointer */
		grafBlit.blitCnt = 1;
	}
	else
	{	/* do fills */
		/* setup blitlist and call filler for 4 rects */
		/* 1/2 width to left (round odd down) */
		halfWidthLeft = (grafPort.pnSize.X >> 1);
		/* 1/2 width to right (round odd up) */
		halfWidthRight = ((grafPort.pnSize.X + 1) >> 1);
		/* 1/2 height up (round odd down) */
		halfHeightUp = (grafPort.pnSize.Y >> 1);
		/* 1/2 height down (round odd up) */
		halfHeightDown = ((grafPort.pnSize.Y + 1) >> 1);

		R[0].Xmin = tempRect.Xmin - halfWidthLeft;	/* top */
		R[0].Ymin = tempRect.Ymin - halfHeightUp;
		R[0].Xmax = tempRect.Xmax + halfWidthRight;
		R[0].Ymax = tempRect.Ymin + halfHeightDown;
	      
		R[1].Xmin = tempRect.Xmin - halfWidthLeft;	/* bottom */
		R[1].Ymin = tempRect.Ymax - halfHeightUp;
		R[1].Xmax = tempRect.Xmax + halfWidthRight;
		R[1].Ymax = tempRect.Ymax + halfHeightDown;

		R[2].Xmin = tempRect.Xmin - halfWidthLeft;	/* left */
		R[2].Ymin = tempRect.Ymin + halfHeightDown;
		R[2].Xmax = tempRect.Xmin + halfWidthRight;
		R[2].Ymax = tempRect.Ymax - halfHeightUp;

		R[3].Xmin = tempRect.Xmax - halfWidthLeft;	/* right */
		R[3].Ymin = tempRect.Ymin + halfHeightDown;
		R[3].Xmax = tempRect.Xmax + halfWidthRight;
		R[3].Ymax = tempRect.Ymax - halfHeightUp;

		grafBlit.blitList = (long) &R[0];	/* set pointer to our blitlist */
		grafBlit.blitCnt = 4;

		grafBlit.blitDmap->prFill(&grafBlit);	/* draw filled rectangle */

		grafBlit.blitList = (long) &grafBlist;	/* restore standard blit list pointer */
		grafBlit.blitCnt = 1;
	}

	return;
}

⌨️ 快捷键说明

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