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

📄 regclip.c

📁 与Nucleus Plus配套的图形库
💻 C
📖 第 1 页 / 共 4 页
字号:
	horizontally or we move to another band, then draw destRect clipped
	to each region rect until we either find a region rect that doesn't
	overlap or we move to another band, then scan until we move to another
	band. If the next band isn't past the top of destRect, repeat. */
	bRect = *fillRect;	/* make a copy of dest rect, because we're going
						to alter the standard copy each time we clip it
						to a region rect */

	do {	/* clipping and drawing loop */
		/* remember bottom edge of this YX band */
		bandYmin = regionRectPtr->Ymin;
		/* set Y extent of dest rect, clipped to the Y extent of this YX band */
		if (bRect.Ymin < regionRectPtr->Ymin)
		{
			dYminTemp = regionRectPtr->Ymin;
		}
		else
		{
			dYminTemp = bRect.Ymin;
		}

		if (bRect.Ymax > regionRectPtr->Ymax)
		{
			dYmaxTemp = regionRectPtr->Ymax;
		}
		else
		{
			dYmaxTemp = bRect.Ymax;
		}

		/* Find the left end of the YX band by scanning to the left until
		the band changes. Actually overscans by one, ending up pointing
		to the rightmost rect in the next YX band. */
		do{
			regionRectPtr--;
		} while (regionRectPtr->Ymin == bandYmin);

		tempRegionPtr = regionRectPtr;	/* remember where the next band
										starts */
		regionRectPtr++;	/* point to the leftmost region rect in the
							current YX band */

		/* skip region rects in this band that are fully to the left of
		dest rect */
		while (bRect.Xmin >= regionRectPtr->Xmax)
		{
			regionRectPtr++;
			/* switch to next band if we just changed bands */
			if (regionRectPtr->Ymin != bandYmin) goto BandBottom;
		}

		/* start clipping and drawing */
		while (bRect.Xmax > regionRectPtr->Xmin)
		{
			/* set the Y extent of the rectangle to draw (base rect clipped
			to YX band) */
			dRect.Ymin = dYminTemp;
			dRect.Ymax = dYmaxTemp;
			if (bRect.Xmax > regionRectPtr->Xmax)
			{
				dRect.Xmax = regionRectPtr->Xmax;
			}
			else
			{
				dRect.Xmax = bRect.Xmax;
			}

			if (bRect.Xmin < regionRectPtr->Xmin)
			{
				dRect.Xmin = regionRectPtr->Xmin;
			}
			else
			{
				dRect.Xmin = bRect.Xmin;
			}

			/* fill the dest rect clipped to the region rect */
			FillDrawer(fcRec);

			regionRectPtr++;
			/* switch to next band if we just changed bands */
			if (regionRectPtr->Ymin != bandYmin) goto BandBottom;
		}

		/* skip region rects in this band that are fully to the right of
		dest rect; basically, scan to the next YX band */
BandBottom:
		regionRectPtr = tempRegionPtr;	/* point to the rightmost end of 
										the next YX band */
	/* continue as long as the dest rect's top is above the region
	rect's bottom (they overlap vertically) */
	} while (bRect.Ymin < regionRectPtr->Ymax);

	#endif

	return;
}


/* Function Blit_Clip_Region_TB_RL fills/blits a rectangle, clipped to a
region, processing the region from top->bottom, and right->left within
each band for the blit routines.  Returns a 0 if YX banded and there are
more rectangles to draw, else 0.

Parameters:
	fcRec = pointer to blitRcd
	fillRect = pointer rect to draw, already clipped to the clip rect
	sRect = pointer rect to draw from, already clipped to the clip rect; Ymin
	must be less than 0x7fff

The following regclipv.h common variables are required:
	FillDrawer = routine to call to draw each region-clipped rect
	nextRegionPtr must be set to the point at which to start scanning 
	through the region rect list (on exit, updated to start point for
	scanning next time)
	lclbfYXBanded = !0 if the blitList of rects to draw is YX banded, 0
	otherwise (used to advance nextRegionPtr, and to exit early when
	possible)
	tempRegionPtr, bXmin, bYmin, bXmax, bYmax, bandYmin, dYminTemp, dYmaxTemp,
	bsXmin, bsYmin, bsXmax and bsYmax, sYminTemp and sYmaxTemp */
int Blit_Clip_Region_TB_RL(blitRcd *fcRec, rect *fillRect, rect *sRect)
{
	#ifndef NO_REGION_CLIP
	rect *regionRectPtr;

	regionRectPtr = nextRegionPtr;	/* point to the first region rect at
									which to start clipping */
	/* Find a region band not entirely below dest rect. */
	while (fillRect->Ymin >= regionRectPtr->Ymax)
	{
		regionRectPtr++;
	}

	/* Start at this point next time if the blitRcd is YX banded. */
	if (lclbfYXBanded != 0) nextRegionPtr = regionRectPtr;

	/* Skip if the band is entirely below dest rect. */
	if (fillRect->Ymax <= regionRectPtr->Ymin)  goto BandFullyBelow;

	/* Scan from the left until we find the right end of the band, then
	so long as we're in a band that overlaps vertically with destRect, scan
	back from there to the left until we find a region rect that overlaps
	horizontally or we move to another band, then draw destRect clipped
	to each region rect until we either find a region rect that doesn't
	overlap or we move to another band, then scan until we move to another
	band. If the next band isn't past the bottom of destRect, repeat. */
	bRect = *fillRect;	/* make a copy of dest rect, because we're going
						to alter the standard copy each time we clip it
						to a region rect */
	bsRect = *sRect;	/* likewise, make a copy of the source rect */

	do {	/* clipping and drawing loop */
		/* remember bottom edge of this YX band */
		bandYmin = regionRectPtr->Ymin;
		/* set Y extent of dest rect, clipped to the Y extent of this YX band */
		if (bRect.Ymin < regionRectPtr->Ymin)
		{
			dYminTemp = regionRectPtr->Ymin;
			sYminTemp = bsRect.Ymin - (bRect.Ymin - dYminTemp);
		}
		else
		{
			dYminTemp = bRect.Ymin;
			sYminTemp = bsRect.Ymin;
		}

		if (bRect.Ymax > regionRectPtr->Ymax)
		{
			dYmaxTemp = regionRectPtr->Ymax;
			sYmaxTemp = bsRect.Ymax - (bRect.Ymax - dYmaxTemp);
		}
		else
		{
			dYmaxTemp = bRect.Ymax;
			sYmaxTemp = bsRect.Ymax;
		}

		/* Find the right end of the YX band by scanning to the right until
		the band changes. Actually overscans by one, ending up pointing
		to the leftmost rect in the next YX band. */
		do{
			regionRectPtr++;
		} while (regionRectPtr->Ymin == bandYmin);

		tempRegionPtr = regionRectPtr;	/* remember where the next band
										starts */
		regionRectPtr--;	/* point to the rightmost region rect in the
							current YX band */

		/* skip region rects in this band that are fully to the right of
		dest rect */
		while (bRect.Xmax <= regionRectPtr->Xmin)
		{
			regionRectPtr--;
			/* switch to next band if we just changed bands */
			if (regionRectPtr->Ymin != bandYmin) goto BandBottom;
		}

		/* start clipping and drawing */
		while (bRect.Xmin < regionRectPtr->Xmax)
		{
			/* set the Y extent of the rectangle to draw (base rect clipped
			to YX band) */
			dRect.Ymin = dYminTemp;
			dRect.Ymax = dYmaxTemp;
			/* set the Y extent of the rectangle from which to draw (base
			source rect clipped to YX band) */
			sRect->Ymin = sYminTemp;
			sRect->Ymax = sYmaxTemp;
			if (bRect.Xmax > regionRectPtr->Xmax)
			{
				dRect.Xmax = regionRectPtr->Xmax;
				sRect->Xmax = bsRect.Xmax - (bRect.Xmax - dRect.Xmax);
			}
			else
			{
				dRect.Xmax = bRect.Xmax;
				sRect->Xmax = bsRect.Xmax;
			}

			if (bRect.Xmin < regionRectPtr->Xmin)
			{
				dRect.Xmin = regionRectPtr->Xmin;
				sRect->Xmin = bsRect.Xmin - (bRect.Xmin - dRect.Xmin);
			}
			else
			{
				dRect.Xmin = bRect.Xmin;
				sRect->Xmin = bsRect.Xmin;
			}

			/* fill the dest rect clipped to the region rect */
			FillDrawer(fcRec);

			regionRectPtr--;
			/* switch to next band if we just changed bands */
			if (regionRectPtr->Ymin != bandYmin) goto BandBottom;
		}

BandBottom:
		regionRectPtr = tempRegionPtr;	/* point to the rightmost end of 
										the next YX band */
	/* continue as long as the dest rect's top is above the region
	rect's bottom (they overlap vertically) */
	} while (bRect.Ymax > regionRectPtr->Ymin);
	return(1);	/* get next rectangle */

BandFullyBelow:
	if (regionRectPtr->Ymin != 0x7fff) return(0);
	if (lclbfYXBanded != 0) return(1);

	#endif

	return(0);
}


/* Function Fill_Clip_Region_TB_RL fills a rectangle, clipped to a
region, processing the region from top->bottom, and right->left within
each band for the blit routines.  Returns a 0 if YX banded and there are
more rectangles to draw, else 0.

Parameters:
	fcRec = pointer to blitRcd
	fillRect = pointer rect to draw, already clipped to the clip rect

The following regclipv.h common variables are required:
	FillDrawer = routine to call to draw each region-clipped rect
	nextRegionPtr must be set to the point at which to start scanning 
	through the region rect list (on exit, updated to start point for
	scanning next time)
	lclbfYXBanded = !0 if the blitList of rects to draw is YX banded, 0
	otherwise (used to advance nextRegionPtr, and to exit early when
	possible)
	tempRegionPtr, bXmin, bYmin, bXmax, bYmax, bandYmin, dYminTemp
	and dYmaxTemp */
int Fill_Clip_Region_TB_RL(blitRcd *fcRec, rect *fillRect)
{
	#ifndef NO_REGION_CLIP
	rect *regionRectPtr;

	regionRectPtr = nextRegionPtr;	/* point to the first region rect at
									which to start clipping */
	/* Find a region band not entirely below dest rect. */
	while (fillRect->Ymin >= regionRectPtr->Ymax)
	{
		regionRectPtr++;
	}

	/* Start at this point next time if the blitRcd is YX banded. */
	if (lclbfYXBanded != 0) nextRegionPtr = regionRectPtr;

	/* Skip if the band is entirely below dest rect. */
	if (fillRect->Ymax <= regionRectPtr->Ymin)  goto BandFullyBelow;

	/* Scan from the left until we find the right end of the band, then
	so long as we're in a band that overlaps vertically with destRect, scan
	back from there to the left until we find a region rect that overlaps
	horizontally or we move to another band, then draw destRect clipped
	to each region rect until we either find a region rect that doesn't
	overlap or we move to another band, then scan until we move to another
	band. If the next band isn't past the bottom of destRect, repeat. */
	bRect = *fillRect;	/* make a copy of dest rect, because we're going
						to alter the standard copy each time we clip it
						to a region rect */
	do {	/* clipping and drawing loop */
		/* remember bottom edge of this YX band */
		bandYmin = regionRectPtr->Ymin;
		/* set Y extent of dest rect, clipped to the Y extent of this YX band */
		if (bRect.Ymin < regionRectPtr->Ymin)
		{
			dYminTemp = regionRectPtr->Ymin;
		}
		else
		{
			dYminTemp = bRect.Ymin;
		}

		if (bRect.Ymax > regionRectPtr->Ymax)
		{
			dYmaxTemp = regionRectPtr->Ymax;
		}
		else
		{
			dYmaxTemp = bRect.Ymax;
		}

		/* Find the right end of the YX band by scanning to the right until
		the band changes. Actually overscans by one, ending up pointing
		to the leftmost rect in the next YX band. */
		do{
			regionRectPtr++;
		} while (regionRectPtr->Ymin == bandYmin);

		tempRegionPtr = regionRectPtr;	/* remember where the next band
										starts */
		regionRectPtr--;	/* point to the rightmost region rect in the
							current YX band */

		/* skip region rects in this band that are fully to the right of
		dest rect */
		while (bRect.Xmax <= regionRectPtr->Xmin)
		{
			regionRectPtr--;
			/* switch to next band if we just changed bands */
			if (regionRectPtr->Ymin != bandYmin) goto BandBottom;
		}

		/* start clipping and drawing */
		while (bRect.Xmin < regionRectPtr->Xmax)
		{
			/* set the Y extent of the rectangle to draw (base rect clipped
			to YX band) */
			dRect.Ymin = dYminTemp;
			dRect.Ymax = dYmaxTemp;
			if (bRect.Xmax > regionRectPtr->Xmax)
			{
				dRect.Xmax = regionRectPtr->Xmax;
			}
			else
			{
				dRect.Xmax = bRect.Xmax;
			}

			if (bRect.Xmin < regionRectPtr->Xmin)
			{
				dRect.Xmin = regionRectPtr->Xmin;
			}
			else
			{
				dRect.Xmin = bRect.Xmin;
			}

			/* fill the dest rect clipped to the region rect */
			FillDrawer(fcRec);

			regionRectPtr--;
			/* switch to next band if we just changed bands */
			if (regionRectPtr->Ymin != bandYmin) goto BandBottom;
		}

BandBottom:
		regionRectPtr = tempRegionPtr;	/* point to the rightmost end of 
										the next YX band */
	/* continue as long as the dest rect's top is above the region
	rect's bottom (they overlap vertically) */
	} while (bRect.Ymax > regionRectPtr->Ymin);
	return(1);	/* get next rectangle */

BandFullyBelow:
	if (regionRectPtr->Ymin != 0x7fff) return(0);
	if (lclbfYXBanded != 0) return(1);

	#endif

	return(0);
}

⌨️ 快捷键说明

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