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

📄 strk1.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          */
/*                                                                       */
/*      STRK1.c                                          1.9             */
/*                                                                       */
/* COMPONENT                                                             */
/*                                                                       */
/*      All                                                              */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This file contains the mwSTRKINI function.                       */
/*                                                                       */
/* AUTHOR                                                                */
/*                                                                       */
/*      Giac Dinh, Accelerated Technology, Inc.                          */
/*                                                                       */
/* DATA STRUCTURES                                                       */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* FUNCTIONS                                                             */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* DEPENDENCIES                                                          */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* HISTORY                                                               */
/*                                                                       */
/*         NAME            DATE                    REMARKS               */
/*                                                                       */
/*         GiacD          2/8/99     Added fixed-point math support      */
/*         BobB           11/9/99    Removed unused variable             */
/*                                                                       */
/*************************************************************************/

#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 "metfonts.h"
//#include "Nu_math.h"

 
/* Function mwSTRKINI initializes the current font for stroked font
processing by pre-computing a number of variables.
	
mwSTRKINI is called indirectly via the txDrwIDV vector whenever stroked
text is to be drawn but has not been initialized. mwSTRKINI initializes
the stroked font system, replaces the txDrwIDV vector with the stroked font
drawing routine, and the issues a call to the stroked font drawing routine.

Further calls via txDrwIDV will vector directly to the stroked font drawing
routine, bypassing initialization.

The following formulas are used in processing global bitmap coordinates:

	A = -A;  {angle}
	x' = (x*cosA*resY + y*sinA*resX)/ resY
	y' = (y*cosA*resX - x*sinA*resY)/ resX

	x' = x*cosA + y*sinA*resX/resY;
	y' = y*cosA - x*sinA*resY/resX;

scaling for unit size (sizeX/fxSpac) & (sizeY/leading):

	A = -(txPath + txAngle);
	x' = x*(sizeX/fxSpac)*cosA + y*(sizeY/leading)*((sinA*resX)/resY));
	y' = y*(sizeY/leading)*cosA - x*(sizeX/fxWidth)*((sinA*resY)/resX));

   let:
	qDxx = (sizeX/fxSpac)*cosA;
	qDxy = (sizeY/leading)*((sinA*resX)/resY));
	qDyy = (sizeY/leading)*cosA;
	qDyx = (sizeX/fxWidth)*((sinA*resY)/resX));

   then:
	x' = x*qDxx + y*qDxy;
	y' = y*qDyy - x*qDyx;  */

#ifdef FIXPOINT
void mwSTRKINI(char *TEXT, int INDEX, int COUNT , int CHARSIZE )
{
	void mwStrokeText();
	
	/* these are double in the floating point but they don't
	seem to need to be */
	long tLead, tSpace, txSizeX, txSizeY; 
	long qPathSin, qPathCos;
	long  tempAngle,tempSinCos;
	long qTmp1, qTmp2;
	long bmResX, bmResY, bmTan, bmCot;	
	long slantSF = 0x7FFF0000;
/* BobB 11/9/99 - removed the following variable since is never used
	long tem = 0x07080000; */

	fontRcd *Font;
	
	Font = (fontRcd *) grafPort.txFont;
	StrokeFlags = 0;

/* Pickup the resolution values from the bitmap  */
	bmResX = grafPort.portMap->pixResX << 16;
	bmResY = grafPort.portMap->pixResY << 16;
	bmTan = Fix_div(bmResX,bmResY);
	bmCot = Fix_div(bmResY,bmResX);

/* Pickup some things from the font  */
	tLead = Font->leading << 16;
	tSpace = Font->fxSpac << 16;

	if(grafPort.txSize.X <= 0 )
		grafPort.txSize.X = Font->chWidth;

	if(grafPort.txSize.Y <= 0 )
		grafPort.txSize.Y = Font->chHeight;
	
	txSizeX = grafPort.txSize.X << 16;
	txSizeY = grafPort.txSize.Y << 16;

	if(grafPort.txPath != 0 )
		StrokeFlags = StrokeFlags | path;
	if(grafPort.txAngle != 0 )
		StrokeFlags = StrokeFlags | angle;

/* Compute Slant variables  */
	if((grafPort.txFace & faceItalic) && (grafPort.txSlant != 0))
	{
		StrokeFlags = StrokeFlags | slant;
		tempSinCos = iSin(grafPort.txSlant);
		if (tempSinCos < 0)
		{
			StrokeFlags = StrokeFlags | signSlantSin;
			tempSinCos = -tempSinCos;
		}

		sinSlant = Fix_mul(slantSF,tempSinCos);
	
		tempSinCos = iCos(grafPort.txSlant);
		if (tempSinCos < 0)
		{
			StrokeFlags = StrokeFlags | signSlantCos;
			tempSinCos = -tempSinCos;
		}

		cosSlant = Fix_mul(slantSF,tempSinCos);
	}

/* Compute path variables  */
	qPathSin = iSin(grafPort.txPath);
	qPathCos = iCos(grafPort.txPath);

	qTmp1 = Fix_div(txSizeX,tSpace);
	qTmp2 = Fix_div(txSizeY,tLead);

	qPxx = Fix_mul(qTmp1, qPathCos);
	qPyy = Fix_mul(qTmp2, qPathCos);
	qPxy = Fix_mul(qTmp2, qPathSin);
	qPxy = Fix_mul(qPxy, bmTan);
	qPyx = Fix_mul(qTmp1,qPathSin);
	qPyx = Fix_mul(qPyx, bmCot);

	tempAngle = -(grafPort.txPath + grafPort.txAngle);
	qPathSin =  iSin(tempAngle);
	qPathCos =  iCos(tempAngle);

	qDxx = Fix_mul(qTmp1, qPathCos);
	qDyy = Fix_mul(qTmp2, qPathCos);
	qDxy = Fix_mul(qTmp2, qPathSin);
	qDxy = Fix_mul(qDxy, bmTan);
	qDyx = Fix_mul(qTmp1, qPathSin);
	qDyx = Fix_mul(qDyx, bmCot);

/* Set draw vectors to real draw routine  */
	txtDrwIDV =  mwStrokeText;
	txtAlnIDV =  mwStrokeText;
	if(grafPort.txAlign.X != alignLeft)
		txtAlnIDV = txtAPPIDV;

/* Issue draw call  */
	mwStrokeText(TEXT,INDEX,COUNT,CHARSIZE);
	return;
}

#else /* floating-point math */
void mwSTRKINI(char *TEXT, int INDEX, int COUNT , int CHARSIZE )
{

void mwStrokeText();
	
	double tLead, tSpace; 
	double qPathSin, qPathCos;
	double tempAngle, tempSinCos;
	double qTmp1, qTmp2;
	double bmResX, bmResY, bmTan, bmCot;	
	double slantSF = 32767;
	
	fontRcd *Font;
	
	Font = (fontRcd *) grafPort.txFont;
	StrokeFlags = 0;

/* Pickup the resolution values from the bitmap  */
	bmResX = grafPort.portMap->pixResX;
	bmResY = grafPort.portMap->pixResY;
	bmTan = bmResX / bmResY;
	bmCot = bmResY / bmResX;

/* Pickup some things from the font  */
	tLead = Font->leading;
	tSpace = Font->fxSpac;

	if(grafPort.txSize.X <= 0 )
		grafPort.txSize.X = Font->chWidth;

	if(grafPort.txSize.Y <= 0 )
		grafPort.txSize.Y = Font->chHeight;

	if(grafPort.txPath != 0 )
		StrokeFlags = StrokeFlags | path;
	if(grafPort.txAngle != 0 )
		StrokeFlags = StrokeFlags | angle;

/* Compute Slant variables  */
	if((grafPort.txFace & faceItalic) && (grafPort.txSlant != 0))
	{
		StrokeFlags = StrokeFlags | slant;
		tempAngle = 3.1415926535 * grafPort.txSlant / 1800.0;

		tempSinCos = sin(tempAngle);
		if (tempSinCos < 0)
		{
			StrokeFlags = StrokeFlags | signSlantSin;
			tempSinCos = -tempSinCos;
		}

		sinSlant = (short)(slantSF * tempSinCos);
	
		tempSinCos = cos(tempAngle);
		if (tempSinCos < 0)
		{
			StrokeFlags = StrokeFlags | signSlantCos;
			tempSinCos = -tempSinCos;
		}

		cosSlant = (short)(slantSF * tempSinCos);
	}

/* Compute path variables  */
	tempAngle = 3.1415926535 * grafPort.txPath / 1800.0;
	qPathSin = sin(tempAngle);
	qPathCos = cos(tempAngle);

	qTmp1 = (float) grafPort.txSize.X / (float) tSpace;
	qTmp2 = (float) grafPort.txSize.Y / (float) tLead;

	qPxx = (float) (qTmp1 * qPathCos);
	qPyy = (float) (qTmp2 * qPathCos);
	qPxy = (float) (qTmp2 * qPathSin * bmTan);
	qPyx = (float) (qTmp1 * qPathSin * bmCot);

	tempAngle = -3.1415926535 * (grafPort.txPath + grafPort.txAngle) / 1800.0;
	qPathSin = sin(tempAngle);
	qPathCos = cos(tempAngle);

	qDxx = (float) (qTmp1 * qPathCos);
	qDyy = (float) (qTmp2 * qPathCos);
	qDxy = (float) (qTmp2 * qPathSin * bmTan);
	qDyx = (float) (qTmp1 * qPathSin * bmCot);

/* Set draw vectors to real draw routine  */
	txtDrwIDV =  mwStrokeText;
	txtAlnIDV =  mwStrokeText;
	if(grafPort.txAlign.X != alignLeft)
		txtAlnIDV = txtAPPIDV;

/* Issue draw call  */
	mwStrokeText(TEXT,INDEX,COUNT,CHARSIZE);
	return;
}
#endif

⌨️ 快捷键说明

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