#include <Types.h>#include <Memory.h>#include <Quickdraw.h>#include <Fonts.h>#include <Events.h>#include <Menus.h>#include <Windows.h>#include <TextEdit.h>#include <Dialogs.h>#include <OSUtils.h>#include <ToolUtils.h>#include <SegLoad.h>#include <Sound.h>#include <math.h>/* Globals */Rect	windRect;int numPoints = 10;/* Prototypes */void Initialize(void);void CreatePoly(Polygon **, double polyPoints[10][2], RGBColor *polyColor);void RotatePoly(double *polyPoints, double angle);void ScalePoly(double *polyPoints, double x, double y);void TranslatePoly(double *polyPoints, double x, double y);int main(void){	EventRecord anEvent;	WindowPtr   evtWind;	RGBColor	polyColor;	int transformations;	Polygon **myPoly;		/* Initial Polygon Points */	double polyPoints[10][2] = {{0,200}, {50,100}, {150,100}, {80,0}, {100,-100}, {0,-50}, {-100,-100}, {-80,0}, {-150,100}, {-50,100}};		polyColor.red = 60000;	polyColor.green = 10000;	polyColor.blue = 10000;	Initialize();		for (transformations=0; transformations<50; transformations++)	{		/* Color changes */		if (polyColor.red == 10000)		{			polyColor.red = 60000;			polyColor.blue = 10000;			polyColor.green = 10000;		} else		{			polyColor.red = polyColor.red - 10000;			polyColor.green = polyColor.green + 60000;			polyColor.blue = 10000;		}		/* 2D Transformations */		CreatePoly(myPoly, polyPoints, &polyColor);		RotatePoly(*polyPoints, 90);		ScalePoly(*polyPoints, 90,90);		TranslatePoly(*polyPoints, 50,50);	}				for (;;)	{		if (WaitNextEvent( everyEvent, &anEvent, 0, nil ))		{			if (anEvent.what == mouseDown)			{				return 0;			}			else if (anEvent.what == updateEvt)			{				evtWind = (WindowPtr)anEvent.message;					SetPortWindowPort( evtWind );				BeginUpdate( evtWind );				EndUpdate (evtWind);			}		}	}		return 0;}void TranslatePoly(double *polyPoints, double x, double y){	int i;	for (i=0;i<numPoints*2;i=i+2) {		polyPoints[i] = polyPoints[i] + x;		polyPoints[i+1] = polyPoints [i+1] + y;	}}void ScalePoly(double *polyPoints, double x, double y){	int i;	for (i=0;i<numPoints*2;i=i+2) {		polyPoints[i] = polyPoints[i] * x/100;		polyPoints[i+1] = polyPoints[i+1] * y/100;	}}void RotatePoly(double *polyPoints, double angle){	double tempx;	int i;	for (i=0;i<numPoints*2;i=i+2) {		tempx = polyPoints[i];		polyPoints[i] = (polyPoints[i]*cos(angle)) - (polyPoints[i+1]*sin(angle));		polyPoints[i+1] = (tempx*sin(angle)) + (polyPoints[i+1]*cos(angle));	}}void CreatePoly(Polygon **myPoly, double polyPoints[10][2], RGBColor *polyColor){	int i;		RGBForeColor (polyColor);	myPoly = OpenPoly();	MoveTo(((polyPoints[numPoints-1][0]) + windRect.right/2), (-(polyPoints[numPoints-1][1])) + windRect.bottom/2);	for (i=0; i<numPoints; i++)	{		LineTo(((polyPoints[i][0]) + windRect.right/2), (-(polyPoints[i][1])) + windRect.bottom/2);	}	ClosePoly();	PaintPoly(myPoly);	KillPoly(myPoly);}void Initialize(void){	WindowPtr	mainPtr;	OSErr		error;	SysEnvRec	theWorld;	error = SysEnvirons(1, &theWorld);	if (theWorld.hasColorQD == false) {		SysBeep(50);		ExitToShell();	}	InitGraf(&qd.thePort);	InitFonts();	InitWindows();	InitMenus();	TEInit();	InitDialogs(nil);	InitCursor();	GetDateTime((unsigned long*) &qd.randSeed);	windRect = qd.screenBits.bounds;	InsetRect(&windRect, 50, 50);	mainPtr = NewCWindow(nil, &windRect, "\pStuarts First Graphics Assignment", true, documentProc, 						(WindowPtr) -1, false, 0);	SetPort(mainPtr);}
