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

📄 xpol4.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          */
/*                                                                       */
/*      XPOL4.c                                          1.9             */
/*                                                                       */
/* COMPONENT                                                             */
/*                                                                       */
/*      All                                                              */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This file contains the BuildGET, AddEdgeToGET & FillPolygon      */
/* functions.                                                            */
/*                                                                       */
/* 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"
#include "xpol_5.h"

/* Local Functions  */
void mwFC(byte *lclScratchBufferPtr, long lclScratchBufferSize,
		  point * points, int npoints, int mode,
		  long lclXAdjust, long lclYAdjust);
void mwScanGET(void **GETPtrPtr, blitRcd *fillRcd, int scanRcdSize, int shape,
			   int fillRule, int allEdgesAreLines);
void __mwSL(void);

/* Function BuildGET builds a global edge table from the point list.
The GET is a linked list,  sorted first by Y coordinate, then by
X coordinate.

Returns 1 for success, 0 for failure (insufficient memory). */

short BuildGET(void)
{
	point *vrtxListPtr;	/* local copy of vertexListPtr for wrap back */

	rawLastX = vertexListPtr->X;	/* remember this X,Y for next time */
	rawLastY = vertexListPtr->Y;
	vrtxListPtr = vertexListPtr;

	if (globalLevel > 0)	/* already in global? */
	{	/* no, convert to global */
		U2GP(rawLastX, rawLastY, &nextStartX, &nextStartY, 0);
	}
	else
	{
		nextStartX = rawLastX;
		nextStartY = rawLastY;
	}

	do {
		if(lclNpointsparm == 1)	/* is this the last vertex? */
		{	/* yes, so wrap back to the first point */
			/* load the endpoint of this segment and convert it
			to global coords */
			rawLastX = vertexListPtr->X;
			rawLastY = vertexListPtr->Y;
		}
		else
		{
			vrtxListPtr++;	/* point to the next vertex */
			if (lclModeparm == coordModePrevious)	/* previous mode? */
			{	/* yes, calculate new position as a delta from the
					last X,Y in user coordinates */
				rawLastX += vrtxListPtr->X;
				rawLastY += vrtxListPtr->Y;
			}
			else
			{
				rawLastX = vrtxListPtr->X;
				rawLastY = vrtxListPtr->Y;
			}
		}

		if (globalLevel > 0)	/* already in global? */
		{	/* no, convert to global */
			U2GP(rawLastX, rawLastY, &addEndX, &addEndY, 0);
		}
		else
		{
			addEndX = rawLastX;
			addEndY = rawLastY;
		}

		addStartX = nextStartX;
		addStartY = nextStartY;
		nextStartX = addEndX;
		nextStartY = addEndY;
		if (addEdgeVector() != 1) return(0);	/* fail if return */

	} while (--lclNpointsparm > 0);	/* count down # of points remaining */

	return(1);
}


/* Function AddEdgeToGET adds the edge to the GET, checking for
buffer overflow and maintaining Y primary/X secondary sorting.
Compares edge to clip rect, trivially rejecting if possible, and
adjusting top and length as needed to clip if partially clipped.

Returns 1 for success, 0 for failure (insufficient memory). */

short AddEdgeToGET(void)
{
	short tmpXY;
	short DeltaX;
	short DeltaY;
	lineEdgeV *NextEdgePtr;
	lineEdgeV *pGETPtr;
	lineEdgeV **lGETPtr;

    int getCnt = 0;

	/* is there room for the structure? */
	if (((long) buf1Ptr) >= endAvailForGET) return(0);

	pGETPtr = (lineEdgeV *) buf1Ptr;
	if (addStartY == addEndY) return(1);	/* is this an active edge? */
	if (addStartY < addEndY)
	{	/* the edge is top to bottom, as desired */
		pGETPtr->TopToBottom = 1;
	}
	else
	{	/* swap endpoints to make the edge go top to bottom */
		pGETPtr->TopToBottom = -1;
		tmpXY = addStartX;
		addStartX = addEndX;
		addEndX = tmpXY;
		tmpXY = addStartY;
		addStartY = addEndY;
		addEndY = tmpXY;
	}
	
	/* see if we can trivially reject on the basis of Y coordinates */
	if ((addStartY >= clpR.Ymax) || (addEndY <= clpR.Ymin)) return(1);

	pGETPtr->CurrentX = addStartX;
	pGETPtr->StartY = addStartY;
	DeltaY = addEndY - addStartY;
	pGETPtr->Count = DeltaY;
	pGETPtr->ErrorTermAdjDownV = DeltaY;
	if ((DeltaX = addEndX - addStartX) >= 0)	/* check x direction */
	{	/* left->right */
		pGETPtr->XDirection = 1;
		pGETPtr->ErrorTermV = -1;	/* initial error term */
	}
	else
	{	/* right->left */
		pGETPtr->XDirection = -1;
		pGETPtr->ErrorTermV = -DeltaY;	/* initial error term */
		DeltaX = -DeltaX;	/* abs(DeltaX) */
	}

	if (DeltaY >= DeltaX)	/* X major or Y major? */
	{	/* Y major */
		pGETPtr->WholePixelXMoveV = 0;
		pGETPtr->ErrorTermAdjUpV = DeltaX;
	}
	else
	{	/* X major */
		pGETPtr->ErrorTermAdjUpV = DeltaX % DeltaY;

⌨️ 快捷键说明

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