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

📄 rect5.c

📁 nucleus 文件系统,内核和彩色图形系统,在小系统上非常好用
💻 C
📖 第 1 页 / 共 2 页
字号:
/*************************************************************************/
/*                                                                       */
/*         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          */
/*                                                                       */
/*      RECT5.c                                          1.9             */
/*                                                                       */
/* COMPONENT                                                             */
/*                                                                       */
/*      All                                                              */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This file contains the FrameRoundRect 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"
#include "xpol_4.h"

/* Local functions  */
void mwSBQA(qarcState *QArcEdge, int QArcA, int QArcB, int QArcCenterX,
			int QArcCenterY, int QArcDirection, int QArcTToB);
void AddToGETYXSorted(qarcState *newEdge);
void mwSTQA(qarcState *QArcEdge, int QArcA, int QArcB, int QArcCenterX,
			int QArcCenterY, int QArcDirection, int QArcTToB);
void mwSV(Vedge *VLEdge, int VLX, int VLY, int VLHeight, int VLDir);
void mwScanGET(void **GETPtrPtr, blitRcd *fillRcd, int scanRcdSize, int shape,
			   int fillRule, int allEdgesAreLines);

/* Procedure AddOuterEdges builds a GET containing a set of 4 to 6 outer
edges (vertical edges are only added if they're needed).

Global input is dimensions of bounding rectangle:
  rXmin.Xmin = right edge
  rXmin.Ymin = top edge
  rXWidth = width
  rXHeight = height */

void AddOuterEdges(qarcState *newEdge)
{

	/* if either corner diameter is greater than the corresponding rectangle
	dimension, limit it to the rectangle dimension */

	if (argDiaX < rXWidth) rXWidth = argDiaX;	/* use diameter */
	if (argDiaY < rXHeight) rXHeight = argDiaY;	/* use diameter */

	xRadius = (rXWidth >> 1);
	yRadius = (rXHeight >> 1);

	thisLeftEdge = rXmin.Xmin + xRadius;	/* left edge + height */
	nextTopEdge = rXmin.Ymin + yRadius;	/* top edge + height */
	thisRightEdge = rXmin.Xmax - xRadius + 1;	/* shift right by 1 to compensate for
					the filler not drawing right edges */
	nextBottomEdge = rXmin.Ymax - yRadius;	/* bottom edge - height */

	/* set up the upper left arc */
	GETPtr = &qaEdgeBuffer[0];
	newEdge = GETPtr;
	mwSTQA(newEdge, xRadius, yRadius, thisLeftEdge, nextTopEdge, -1, -1);

	/* set up the upper right arc */
	newEdge = &qaEdgeBuffer[1];
	mwSTQA(newEdge, xRadius, yRadius, thisRightEdge, nextTopEdge, 1, 1);
	AddToGETYXSorted(newEdge);	/* insert the new edge in GET, YX sorted */

	/* set up the lower left arc */
	newEdge = &qaEdgeBuffer[2];
	mwSBQA(newEdge, xRadius, yRadius, thisLeftEdge, nextBottomEdge, 1, -1);
	AddToGETYXSorted(newEdge);	/* insert the new edge in GET, YX sorted */

	/* set up the upper right arc */
	newEdge = &qaEdgeBuffer[3];
	mwSBQA(newEdge, xRadius, yRadius, thisRightEdge, nextBottomEdge, -1, 1);
	AddToGETYXSorted(newEdge);	/* insert the new edge in GET, YX sorted */

	/* now add the vertical outer sides, if applicable */
	vertDirection = -1;	/* assume bottom and top arcs don't  overlap, so
						vertical edges can run in same direction as arcs */
	nextTopEdge = rXmin.Ymin + yRadius + 1;	/* start on the scan line after
						the top arc ends */
	nextBottomEdge = rXmin.Ymax - yRadius;	/* top of bottom arc */
	
	if (nextBottomEdge == nextTopEdge) return;	/* distance is 0; edges fit perfectly */
	if (nextBottomEdge < nextTopEdge)
	{	/* edges overlap by 1; neutralize 1 so we get correct winding rule counts */
		/* point back to bottom scan of top arc; make the edges 1 long, starting
		at the scan line that ends the top edges (inclusive), to neutralize one
		of the arcs; the top & bottom arcs overlap by 1, and that gives one winding
		count too many */
		nextBottomEdge = nextTopEdge;
		nextTopEdge--;
		vertDirection = 1;	/* edges have to run opposite arcs in order to
							neutralize one of them */
	}

	/* add the vertical edges */
	nextBottomEdge -= nextTopEdge;	/* distance between top & bottom, not inclusive */
	newEdge = &qaEdgeBuffer[8];
	mwSV((Vedge *)newEdge, rXmin.Xmin, nextTopEdge, nextBottomEdge, vertDirection);
	AddToGETYXSorted(newEdge);	/* insert the new edge in GET, YX sorted */

	vertDirection = -vertDirection;	/* reverse direction for other side */
	newEdge = &qaEdgeBuffer[11];
	mwSV((Vedge *)newEdge, (rXmin.Xmax + 1), nextTopEdge, nextBottomEdge, vertDirection);
	AddToGETYXSorted(newEdge);	/* insert the new edge in GET, YX sorted */

	return;
}


/* Procedure AddInnerEdges adds a set of 4 to 6 inner edges to GET (vertical
edges are only added if they're needed).

Global input is dimensions of bounding rectangle:
  rXmin.Xmin = right edge
  rXmin.Ymin = top edge
  rXWidth = width
  rXHeight = height */

void AddInnerEdges(qarcState *newEdge)
{

	/* if either corner diameter is greater than the corresponding rectangle
	dimension, limit it to the rectangle dimension */

	if (argDiaX < rXWidth) rXWidth = argDiaX;	/* use diameter */
	if (argDiaY < rXHeight) rXHeight = argDiaY;	/* use diameter */

	xRadius = (rXWidth >> 1);
	yRadius = (rXHeight >> 1);

	thisLeftEdge = rXmin.Xmin + xRadius;	/* left edge + height */
	nextTopEdge = rXmin.Ymin + yRadius;	/* top edge + height */
	thisRightEdge = rXmin.Xmax - xRadius + 1;	/* shift right by 1 to compensate for
					the filler not drawing right edges */
	nextBottomEdge = rXmin.Ymax - yRadius;	/* bottom edge - height */

	/* set up the upper left arc */
	newEdge = &qaEdgeBuffer[4];
	mwSTQA(newEdge, xRadius, yRadius, thisLeftEdge, nextTopEdge, -1, 1);

	/* set up the upper right arc */
	newEdge = &qaEdgeBuffer[5];
	mwSTQA(newEdge, xRadius, yRadius, thisRightEdge, nextTopEdge, 1, -1);

	/* set up the lower left arc */
	newEdge = &qaEdgeBuffer[6];
	mwSBQA(newEdge, xRadius, yRadius, thisLeftEdge, nextBottomEdge, 1, 1);

	/* set up the upper right arc */

⌨️ 快捷键说明

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