💾 Archived View for mirrors.apple2.org.za › archive › apple.cabi.net › Graphics › PICT.and_QT.INFO ›… captured on 2024-05-10 at 15:25:45.

View Raw

More Information

⬅️ Previous capture (2023-01-29)

-=-=-=-=-=-=-

#include <Memory.h>
#include <QuickDraw.h>

#include "curves.h"

#define	POLYBEGIN	160
#define	POLYEND		161
#define	POLYIGNORE	163
#define	POLYSMOOTH	164
#define	PICPOLYCLO	165

#define	kPolyClose	4
#define 	kPolyFill		2
#define	kPolyFrame	1

void AddSegmentToPict( curve* cur, point* delta, int isLine )
{
	Handle verbHdl = NewHandle( 1 );
	RgnHandle origClip = NewRgn();
	Rect emptyRect = { 0, 0, 0, 0 };

	**verbHdl = kPolyFrame;
	GetClip( origClip );

	PicComment( POLYBEGIN, 0, 0 );
	ClipRect(&emptyRect);		/* this turns drawing off */
	PicComment( POLYSMOOTH, 2, verbHdl );
	/*
	 *	Record the endpoints for Postscript
	 */
	fmoveto( cur->start.x + delta->x, cur->start.y + delta->y );
	if (isLine)
		flineto( cur->end.x + delta->x, cur->end.y + delta->y );
	else
		flineto( cur->control.x + delta->x, cur->control.y + delta->y );
	flineto( cur->end.x + delta->x, cur->end.y + delta->y );

	PicComment( POLYIGNORE, 0, 0 );
	SetClip( origClip );			/* this turns drawing back on */
	/*
	 *	Record the lines for QuickDraw
	 */
	fmoveto( cur->start.x, cur->start.y );
	if (isLine)
		flineto( cur->end.x, cur->end.y );
	else
		FrameCurve(cur, kCurveLimit);
	PicComment( POLYEND, 0, 0 );

	DisposeRgn( origClip );
	DisposHandle( verbHdl );
}

AddPathsToPict( paths* myPaths )
{
	point penDelta;
	long i;
	path* cont;

/*	Compute 1/2 the pen's thickness as a delta,
 *	since PostScript's pen is centered, and QuickDraw's hangs to the
 *	right and down.

	penDelta.x = ff(qd.thePort->pnSize.h) / 2;
	penDelta.y = ff(qd.thePort->pnSize.v) / 2;

	/* Record the curve data.
	*/
	cont = myPaths->contour;
	for (i = 0; i < myPaths->contours; i++)
	{	pathWalker walker;

		/*
		 *	This loop looks just like FramePath
		 */
		InitPathWalker(&walker, cont);
		while (NextPathSegment(&walker))
			AddSegmentToPict(&walker.c, &penDelta, walker.isLine);
		cont = NextPath(cont);
	}
}