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

📄 bezr7.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          */
/*                                                                       */
/*      BEZR7.c                                          1.9             */
/*                                                                       */
/* COMPONENT                                                             */
/*                                                                       */
/*      All                                                              */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This file contains the mwBezier 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 mwBezier computes the bezier linear interpolation point array. */

void mwBezier(point *PTS, int PTCNT, point *BEZPTS)
{
	void mwBezDDA(long p0X, long p0Y, long p1X, long p1Y, long p2X, long p2Y,
			      long p3X, long p3Y, int depth);
	int mwBezDepth(point *PTS);
	int i;	/* work variables */
	int j;
	point tP[4];	/* temporary bezier control */
	int bzDepth;
	long c1X;
	long c1Y;
	long h1X;
	long h1Y;
	long h2X;	/* controls */
	long h2Y;
	long c2X;
	long c2Y;

	ptrBEZPTS = BEZPTS;	/* pick up pointer to output */

	/* Generate point list for bezier approximation. */
	for (i = 0; i < (PTCNT - 1); i += 3)
	{
		for (j = 0; j < 4; j++)	/* Process one curve at a time */
		{ 
			/* copy and convert control points to global */
			if (globalLevel > 0)
			{
				U2GP(PTS[i + j].X, PTS[i + j].Y, &tP[j].X, &tP[j].Y, 1);
			}
			else
			{
				tP[j]= PTS[i + j];
			}
		}

		/* store the starting point for the first curve */
		if (i == 0)
		{
			*ptrBEZPTS++ = tP[0];
		}
		/* Calculate the recursion depth (numPts = 2^bzDepth) */
		bzDepth = mwBezDepth((point *)&tP);

		if ( bzDepth == 0 )
		{	/* if bzDepth is zero, this section is a straight line */
			*ptrBEZPTS++ = tP[3];
		}
		else
		{	/* convert global coordinates to special long integer */
			c1X = (tP[0].X << 16);
			c1Y = (tP[0].Y << 16);
			h1X = (tP[1].X << 16);
			h1Y = (tP[1].Y << 16);
			h2X = (tP[2].X << 16);
			h2Y = (tP[2].Y << 16);
			c2X = (tP[3].X << 16);
			c2Y = (tP[3].Y << 16);

			/* calculate the approximation points */
			mwBezDDA(c1X, c1Y, h1X, h1Y, h2X, h2Y, c2X, c2Y, bzDepth);
		}
	}

	return;
}

⌨️ 快捷键说明

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