X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fglyphpoints.cpp;h=2e80e387e4987871dbf6c261ea608ea18b91046d;hb=3ef71393f70213eb53db552605ae3c93f1303ee9;hp=a2b80aa499fa4098cedcaa7f2add13d378ee7a00;hpb=6d13a5166688e470590692eb91c3915ab332fe36;p=ttedit diff --git a/src/glyphpoints.cpp b/src/glyphpoints.cpp index a2b80aa..2e80e38 100755 --- a/src/glyphpoints.cpp +++ b/src/glyphpoints.cpp @@ -1,581 +1,951 @@ -// -// GLYPHPOINTS.CPP -// -// Class implementation. Nothing too inexplicable going on here. Fairly -// straightforward stuff. -// -// by James L. Hammons -// (C) 2004 Underground Software -// -// JLH = James L. Hammons -// -// Who When What -// --- ---------- ------------------------------------------------------------ -// JLH ??/??/200? Created this file -// JLH 05/18/2004 Added pure point adding, inserting, better polygon handling -// - -// Uncomment this for debugging... -#define DEBUG - -#include "glyphpoints.h" -#ifdef DEBUG -#include "debug.h" -#endif - -/*GlyphPoints::GlyphPoints(void) -{ - GlyphPoints(0, 0, NULL, NULL, NULL, NULL); -}*/ - -GlyphPoints::GlyphPoints(int nPts/*=0*/, int nPlys/*=0*/, int * xa/*=null*/, int * ya/*=null*/, - bool * oca/*=null*/, uint16 * pa/*=null*/): x(NULL), y(NULL), onCurve(NULL), polyEnd(NULL) -//GlyphPoints::GlyphPoints(int nPts, int nPlys/*=0*/, int * xa/*=null*/, int * ya/*=null*/, -// bool * oca/*=null*/, uint16 * pa/*=null*/): x(NULL), y(NULL), onCurve(NULL), polyEnd(NULL) -{ - AllocateAndCopy(nPts, nPlys, xa, ya, oca, pa); - - if (nPlys == 0) - { - numPolys = 1; - polyEnd = new uint16[numPolys]; - polyEnd[0] = numPoints - 1; - } -#ifdef DEBUG -WriteLogMsg("GlyphPoints: Default constructor. %u points, %u polys.\n", numPoints, numPolys); -#endif -} - -GlyphPoints::GlyphPoints(int xx, int yy, bool oc) -{ -//Hmm. What to do with this...? - AllocateAndCopy(1, 0, &xx, &yy, &oc, NULL); -#ifdef DEBUG -WriteLogMsg("GlyphPoints: Single point constructor. %u points, %u polys.\n", numPoints, numPolys); -#endif -} - -// Copy constructor (needed for deep copying) - -//GlyphPoints::GlyphPoints(GlyphPoints &c): x(NULL), y(NULL), onCurve(NULL), polyEnd(NULL) -GlyphPoints::GlyphPoints(const GlyphPoints &c): x(NULL), y(NULL), onCurve(NULL), polyEnd(NULL) -{ - *this = c; // Use overloaded operator= -#ifdef DEBUG -WriteLogMsg("GlyphPoints: Copy constructor. %u points, %u polys.\n", numPoints, numPolys); -#endif -} - -GlyphPoints::~GlyphPoints() -{ - if (x) - delete[] x; - - if (y) - delete[] y; - - if (onCurve) - delete[] onCurve; - - if (polyEnd) - delete[] polyEnd; -} - -void GlyphPoints::AllocateAndCopy(int nPts, int nPlys, int * xa, int * ya, bool * oca, uint16 * pa) -{ - numPoints = nPts, numPolys = nPlys; - - if (nPts) - { - x = new int[numPoints]; - y = new int[numPoints]; - onCurve = new bool[numPoints]; - - if (xa) // Copy points in if they're passed in... - for(int i=0; i numPoints) // > because we can insert at end...! - throw GP_OUT_OF_RANGE; - -//This is kinda silly. We can do better than this! !!! FIX !!! - int * totX = new int[numPoints + 1]; - int * totY = new int[numPoints + 1]; - bool * totOnCurve = new bool[numPoints + 1]; - - for(int i=0; i 0) - { - numPolys--; - - for(int i=poly; i= numPolys) -#ifdef DEBUG -{ -WriteLogMsg("Exception: GetNumPoints(uint16). poly=%u, numPolys=%u\xD\xA", poly, numPolys); -#endif - throw GP_OUT_OF_RANGE; -#ifdef DEBUG -} -#endif - - return polyEnd[poly] - (poly == 0 ? -1 : polyEnd[poly - 1]); -} - -uint16 GlyphPoints::GetNumPolys(void) -{ - return numPolys; -} - -int GlyphPoints::GetX(uint16 pt) -{ - if (pt >= numPoints) -#ifdef DEBUG -{ -WriteLogMsg("Exception: GetX(uint16). pt=%u, numPoints=%u\xD\xA", pt, numPoints); -#endif - throw GP_OUT_OF_RANGE; -#ifdef DEBUG -} -#endif - - return x[pt]; -} - -int GlyphPoints::GetY(uint16 pt) -{ - if (pt >= numPoints) -#ifdef DEBUG -{ -WriteLogMsg("Exception: GetY(uint16). pt=%u, numPoints=%u\xD\xA", pt, numPoints); -#endif - throw GP_OUT_OF_RANGE; -#ifdef DEBUG -} -#endif - - return y[pt]; -} - -bool GlyphPoints::GetOnCurve(uint16 pt) -{ - if (pt >= numPoints) -#ifdef DEBUG -{ -WriteLogMsg("Exception: GetOnCurve(uint16). pt=%u, numPoints=%u\xD\xA", pt, numPoints); -#endif - throw GP_OUT_OF_RANGE; -#ifdef DEBUG -} -#endif - - return onCurve[pt]; -} - -int GlyphPoints::GetX(uint16 poly, uint16 pt) -{ - if (pt >= GetNumPoints(poly)) -#ifdef DEBUG -{ -WriteLogMsg("Exception: GetX(uint16, uint16). poly= %u, pt=%u, numPoints=%u\xD\xA", poly, pt, numPoints); -#endif - throw GP_OUT_OF_RANGE; -#ifdef DEBUG -} -#endif - - return x[pt + (poly == 0 ? 0 : polyEnd[poly - 1] + 1)]; -} - -int GlyphPoints::GetY(uint16 poly, uint16 pt) -{ - if (pt >= GetNumPoints(poly)) -#ifdef DEBUG -{ -WriteLogMsg("Exception: GetY(uint16, uint16). poly= %u, pt=%u, numPoints=%u\xD\xA", poly, pt, numPoints); -#endif - throw GP_OUT_OF_RANGE; -#ifdef DEBUG -} -#endif - - return y[pt + (poly == 0 ? 0 : polyEnd[poly - 1] + 1)]; -} - -bool GlyphPoints::GetOnCurve(uint16 poly, uint16 pt) -{ - if (pt >= GetNumPoints(poly)) -#ifdef DEBUG -{ -WriteLogMsg("Exception: GetOnCurve(uint16, uint16). poly= %u, pt=%u, numPoints=%u\xD\xA", poly, pt, numPoints); -#endif - throw GP_OUT_OF_RANGE; -#ifdef DEBUG -} -#endif - - return onCurve[pt + (poly == 0 ? 0 : polyEnd[poly - 1] + 1)]; -} - -uint16 GlyphPoints::GetPolyEnd(uint16 poly) -{ - if (poly >= numPolys) -#ifdef DEBUG -{ -WriteLogMsg("Exception: GetPolyEnd(uint16). poly=%u, numPolys=%u\xD\xA", poly, numPolys); -#endif - throw GP_OUT_OF_RANGE; -#ifdef DEBUG -} -#endif - - return polyEnd[poly]; -} - -void GlyphPoints::OffsetPoints(int xOff, int yOff) -{ - for(int i=0; i= numPolys) -#ifdef DEBUG -{ -WriteLogMsg("Exception: GetPolyEnd(uint16). poly=%u, numPolys=%u\xD\xA", poly, numPolys); -#endif - throw GP_OUT_OF_RANGE; -#ifdef DEBUG -} -#endif - - uint16 polyStart = (poly == 0 ? 0 : polyEnd[poly - 1] + 1); - - for(int i=0; i= numPoints) -#ifdef DEBUG -{ -WriteLogMsg("Exception: SetXY(uint16, int, int). pt=%u, numPoints=%u\xD\xA", pt, numPoints); -#endif - throw GP_OUT_OF_RANGE; -#ifdef DEBUG -} -#endif - - x[pt] = xx, y[pt] = yy; -} - -void GlyphPoints::SetOnCurve(uint16 pt, bool oc) -{ - if (pt >= numPoints) -#ifdef DEBUG -{ -WriteLogMsg("Exception: SetOnCurve(uint16, bool). pt=%u, numPoints=%u\xD\xA", pt, numPoints); -#endif - throw GP_OUT_OF_RANGE; -#ifdef DEBUG -} -#endif - - onCurve[pt] = oc; -} - -uint16 GlyphPoints::GetPrev(uint16 pt) -{ -// pt = 7, polyEnd = 4, 9, 15 - uint16 min = 0, max = numPoints - 1; - - for(int i=0; i 0) - min = polyEnd[i - 1] + 1; - - max = polyEnd[i]; - break; - } - } - - uint16 retVal = pt - 1; - - if (pt == min) - retVal = max; - - return retVal; -} - -uint16 GlyphPoints::GetNext(uint16 pt) -{ - uint16 min = 0, max = numPoints - 1; - - for(int i=0; i 0) - min = polyEnd[i - 1] + 1; - - max = polyEnd[i]; - break; - } - } - - uint16 retVal = pt + 1; - - if (pt == max) - retVal = min; - - return retVal; -} - -// -// Get previous point for this polygon using wraparound. -// Note that pt is a zero-based index! -// -uint16 GlyphPoints::GetPrev(uint16 poly, uint16 pt) -{ - return (pt == 0 ? GetNumPoints(poly) - 1 : pt - 1); -} - -// -// Get next point for this polygon using wraparound. -// Note that pt is a zero-based index! -// -uint16 GlyphPoints::GetNext(uint16 poly, uint16 pt) -{ - return (pt == GetNumPoints(poly) - 1 ? 0 : pt + 1); -} - -uint16 GlyphPoints::GetPoly(uint16 pt) -{ - if (pt >= numPoints) -#ifdef DEBUG -{ -WriteLogMsg("Exception: GetPoly(uint16). pt=%u, numPoints=%u\xD\xA", pt, numPoints); -#endif - throw GP_OUT_OF_RANGE; -#ifdef DEBUG -} -#endif - - for(int i=0; i +// +// Who When What +// --- ---------- ------------------------------------------------------------ +// JLH ??/??/200? Created this file +// JLH 05/18/2004 Added pure point adding, inserting, better polygon handling +// + +// Uncomment this for debugging... +#define DEBUG + +#include "glyphpoints.h" +#ifdef DEBUG +#include "debug.h" +#endif +#include + + +/*GlyphPoints::GlyphPoints(void) +{ + GlyphPoints(0, 0, NULL, NULL, NULL, NULL); +}*/ + +GlyphPoints::GlyphPoints(int nPts/*=0*/, int nPlys/*=0*/, int * xa/*=null*/, int * ya/*=null*/, + bool * oca/*=null*/, uint16 * pa/*=null*/): x(NULL), y(NULL), onCurve(NULL), polyEnd(NULL) +//GlyphPoints::GlyphPoints(int nPts, int nPlys/*=0*/, int * xa/*=null*/, int * ya/*=null*/, +// bool * oca/*=null*/, uint16 * pa/*=null*/): x(NULL), y(NULL), onCurve(NULL), polyEnd(NULL) +{ + AllocateAndCopy(nPts, nPlys, xa, ya, oca, pa); + + if (nPlys == 0) + { + numPolys = 1; + polyEnd = new uint16[numPolys]; + polyEnd[0] = numPoints - 1; + } +#ifdef DEBUG +WriteLogMsg("GlyphPoints: Default constructor. %u points, %u polys.\n", numPoints, numPolys); +#endif +} + + +GlyphPoints::GlyphPoints(int xx, int yy, bool oc) +{ +//Hmm. What to do with this...? + AllocateAndCopy(1, 0, &xx, &yy, &oc, NULL); +#ifdef DEBUG +WriteLogMsg("GlyphPoints: Single point constructor. %u points, %u polys.\n", numPoints, numPolys); +#endif +} + + +// Copy constructor (needed for deep copying) + +//GlyphPoints::GlyphPoints(GlyphPoints &c): x(NULL), y(NULL), onCurve(NULL), polyEnd(NULL) +GlyphPoints::GlyphPoints(const GlyphPoints &c): x(NULL), y(NULL), onCurve(NULL), polyEnd(NULL) +{ + *this = c; // Use overloaded operator= +#ifdef DEBUG +WriteLogMsg("GlyphPoints: Copy constructor. %u points, %u polys.\n", numPoints, numPolys); +#endif +} + + +GlyphPoints::~GlyphPoints() +{ + FreeAllocatedMemory(); +#if 0 + if (x) + delete[] x; + + if (y) + delete[] y; + + if (onCurve) + delete[] onCurve; + + if (polyEnd) + delete[] polyEnd; +#endif +} + + +void GlyphPoints::AllocateAndCopy(int nPts, int nPlys, int * xa, int * ya, bool * oca, uint16 * pa) +{ + numPoints = nPts, numPolys = nPlys; + + if (nPts) + { + x = new int[numPoints]; + y = new int[numPoints]; + onCurve = new bool[numPoints]; + + if (xa) // Copy points in if they're passed in... + for(int i=0; i numPoints) // > because we can insert at end...! + throw GP_OUT_OF_RANGE; + +//This is kinda silly. We can do better than this! !!! FIX !!! + int * totX = new int[numPoints + 1]; + int * totY = new int[numPoints + 1]; + bool * totOnCurve = new bool[numPoints + 1]; + + for(int i=0; i 0) + { + numPolys--; + + for(int i=poly; i= numPolys) +#ifdef DEBUG +{ +WriteLogMsg("Exception: GetNumPoints(uint16). poly=%u, numPolys=%u\xD\xA", poly, numPolys); +#endif + throw GP_OUT_OF_RANGE; +#ifdef DEBUG +} +#endif + + return polyEnd[poly] - (poly == 0 ? -1 : polyEnd[poly - 1]); +} + + +uint16 GlyphPoints::GetNumPolys(void) +{ + return numPolys; +} + + +int GlyphPoints::GetX(uint16 pt) +{ + if (pt >= numPoints) +#ifdef DEBUG +{ +WriteLogMsg("Exception: GetX(uint16). pt=%u, numPoints=%u\xD\xA", pt, numPoints); +#endif + throw GP_OUT_OF_RANGE; +#ifdef DEBUG +} +#endif + + return x[pt]; +} + + +int GlyphPoints::GetY(uint16 pt) +{ + if (pt >= numPoints) +#ifdef DEBUG +{ +WriteLogMsg("Exception: GetY(uint16). pt=%u, numPoints=%u\xD\xA", pt, numPoints); +#endif + throw GP_OUT_OF_RANGE; +#ifdef DEBUG +} +#endif + + return y[pt]; +} + + +bool GlyphPoints::GetOnCurve(uint16 pt) +{ + if (pt >= numPoints) +#ifdef DEBUG +{ +WriteLogMsg("Exception: GetOnCurve(uint16). pt=%u, numPoints=%u\xD\xA", pt, numPoints); +#endif + throw GP_OUT_OF_RANGE; +#ifdef DEBUG +} +#endif + + return onCurve[pt]; +} + + +int GlyphPoints::GetX(uint16 poly, uint16 pt) +{ + if (pt >= GetNumPoints(poly)) +#ifdef DEBUG +{ +WriteLogMsg("Exception: GetX(uint16, uint16). poly= %u, pt=%u, numPoints=%u\xD\xA", poly, pt, numPoints); +#endif + throw GP_OUT_OF_RANGE; +#ifdef DEBUG +} +#endif + + return x[pt + (poly == 0 ? 0 : polyEnd[poly - 1] + 1)]; +} + + +int GlyphPoints::GetNextX(uint16 poly, uint16 pt) +{ + return GetX(poly, GetNext(poly, pt)); +} + + +int GlyphPoints::GetY(uint16 poly, uint16 pt) +{ + if (pt >= GetNumPoints(poly)) +#ifdef DEBUG +{ +WriteLogMsg("Exception: GetY(uint16, uint16). poly= %u, pt=%u, numPoints=%u\xD\xA", poly, pt, numPoints); +#endif + throw GP_OUT_OF_RANGE; +#ifdef DEBUG +} +#endif + + return y[pt + (poly == 0 ? 0 : polyEnd[poly - 1] + 1)]; +} + + +int GlyphPoints::GetNextY(uint16 poly, uint16 pt) +{ + return GetY(poly, GetNext(poly, pt)); +} + + +IPoint GlyphPoints::GetPoint(uint16 poly, uint16 pt) +{ + return IPoint(GetX(poly, pt), GetY(poly, pt), GetOnCurve(poly, pt)); +} + + +IPoint GlyphPoints::GetPoint(uint16 pointNumber) +{ + if (pointNumber > numPoints) + throw GP_OUT_OF_RANGE; + + return IPoint(x[pointNumber], y[pointNumber], onCurve[pointNumber]); +} + + +bool GlyphPoints::GetOnCurve(uint16 poly, uint16 pt) +{ + if (pt >= GetNumPoints(poly)) +#ifdef DEBUG +{ +WriteLogMsg("Exception: GetOnCurve(uint16, uint16). poly= %u, pt=%u, numPoints=%u\xD\xA", poly, pt, numPoints); +#endif + throw GP_OUT_OF_RANGE; +#ifdef DEBUG +} +#endif + + return onCurve[pt + (poly == 0 ? 0 : polyEnd[poly - 1] + 1)]; +} + + +bool GlyphPoints::GetPrevOnCurve(uint16 poly, uint16 pt) +{ + return GetOnCurve(poly, GetPrev(poly, pt)); +} + + +bool GlyphPoints::GetNextOnCurve(uint16 poly, uint16 pt) +{ + return GetOnCurve(poly, GetNext(poly, pt)); +} + + +uint16 GlyphPoints::GetPolyStart(uint16 poly) +{ + if (poly >= numPolys) +#ifdef DEBUG +{ +WriteLogMsg("Exception: GetPolyEnd(uint16). poly=%u, numPolys=%u\xD\xA", poly, numPolys); +#endif + throw GP_OUT_OF_RANGE; +#ifdef DEBUG +} +#endif + + // If it's poly 0, return 0. Otherwise, get the previous poly's end & add one to it + return (poly == 0 ? 0 : polyEnd[poly - 1] + 1); +} + + +uint16 GlyphPoints::GetPolyEnd(uint16 poly) +{ + if (poly >= numPolys) +#ifdef DEBUG +{ +WriteLogMsg("Exception: GetPolyEnd(uint16). poly=%u, numPolys=%u\xD\xA", poly, numPolys); +#endif + throw GP_OUT_OF_RANGE; +#ifdef DEBUG +} +#endif + + return polyEnd[poly]; +} + + +void GlyphPoints::OffsetPoints(int xOff, int yOff) +{ + for(int i=0; i= numPolys) +#ifdef DEBUG +{ +WriteLogMsg("Exception: GetPolyEnd(uint16). poly=%u, numPolys=%u\xD\xA", poly, numPolys); +#endif + throw GP_OUT_OF_RANGE; +#ifdef DEBUG +} +#endif + + uint16 polyStart = (poly == 0 ? 0 : polyEnd[poly - 1] + 1); + + for(int i=0; i= numPoints) +#ifdef DEBUG +{ +WriteLogMsg("Exception: SetXY(uint16, int, int). pt=%u, numPoints=%u\xD\xA", pt, numPoints); +#endif + throw GP_OUT_OF_RANGE; +#ifdef DEBUG +} +#endif + + x[pt] = xx, y[pt] = yy; +} + + +void GlyphPoints::SetOnCurve(uint16 pt, bool oc) +{ + if (pt >= numPoints) +#ifdef DEBUG +{ +WriteLogMsg("Exception: SetOnCurve(uint16, bool). pt=%u, numPoints=%u\xD\xA", pt, numPoints); +#endif + throw GP_OUT_OF_RANGE; +#ifdef DEBUG +} +#endif + + onCurve[pt] = oc; +} + + +void GlyphPoints::SetPoint(const uint16 pointNum, const IPoint point) +{ + if (pointNum >= numPoints) +#ifdef DEBUG +{ +WriteLogMsg("Exception: SetPoint(uint16, IPoint). pt=%u, numPoints=%u\xD\xA", pointNum, numPoints); +#endif + throw GP_OUT_OF_RANGE; +#ifdef DEBUG +} +#endif + + x[pointNum] = point.x, y[pointNum] = point.y, onCurve[pointNum] = point.onCurve; +} + + +uint16 GlyphPoints::GetPrev(uint16 pt) +{ +// pt = 7, polyEnd = 4, 9, 15 + uint16 min = 0, max = numPoints - 1; + + for(int i=0; i 0) + min = polyEnd[i - 1] + 1; + + max = polyEnd[i]; + break; + } + } + + uint16 retVal = pt - 1; + + if (pt == min) + retVal = max; + + return retVal; +} + + +uint16 GlyphPoints::GetNext(uint16 pt) +{ + uint16 min = 0, max = numPoints - 1; + + for(int i=0; i 0) + min = polyEnd[i - 1] + 1; + + max = polyEnd[i]; + break; + } + } + + uint16 retVal = pt + 1; + + if (pt == max) + retVal = min; + + return retVal; +} + + +// +// Get previous point for this polygon using wraparound. +// Note that pt is a zero-based index! +// +uint16 GlyphPoints::GetPrev(uint16 poly, uint16 pt) +{ + return (pt == 0 ? GetNumPoints(poly) - 1 : pt - 1); +} + + +// +// Get next point for this polygon using wraparound. +// Note that pt is a zero-based index! +// +uint16 GlyphPoints::GetNext(uint16 poly, uint16 pt) +{ + return (pt == GetNumPoints(poly) - 1 ? 0 : pt + 1); +} + + +#warning "!!! This function returns incorrect results !!!" +uint16 GlyphPoints::GetPoly(uint16 pt) +{ + if (pt >= numPoints) +#ifdef DEBUG +{ +WriteLogMsg("Exception: GetPoly(uint16). pt=%u, numPoints=%u\xD\xA", pt, numPoints); +#endif + throw GP_OUT_OF_RANGE; +#ifdef DEBUG +} +#endif + + for(int i=0; i polyEnd[poly]) + poly++; + + if (IPoint(x[i], y[i]) == point) + return poly; + } + + return 0xFFFF; +} + + +uint16 GlyphPoints::GetPolyForPointNumber(uint16 pointNumber) +{ + // If there's only one poly, we know where the point is... + if (numPolys <= 1) + return 0; + + // Otherwise, do a linear search through the polys to find the right one + for(uint16 i=0; i= GetPolyStart(i) && pointNumber <= polyEnd[i]) + return i; + } + + return 0xFFFF; +} + + +// +// Rotate a point by "angle" around point "center" +// +IPoint GlyphPoints::RotatePoint(const double angle, const IPoint point, const IPoint center) +{ + // Translate the point to the origin + double xt = (double)(point.x - center.x); + double yt = (double)(point.y - center.y); + + // Rotate the point by angle + double xr = (xt * cos(angle)) - (yt * sin(angle)); + double yr = (xt * sin(angle)) + (yt * cos(angle)); + + // Translate it back... + IPoint rotated; + rotated.x = (int)(xr + 0.5) + center.x; + rotated.y = (int)(yr + 0.5) + center.y; + return rotated; +} + + +// +// Rotate all points in the glyph by "angle" around point "pt" +// +void GlyphPoints::RotatePoints(const double angle, const IPoint pt) +{ + for(int i=0; i= numPolys) + throw GP_OUT_OF_RANGE; +// return IPoint(0, 0); + +// if (poly >= numPolys) +//#ifdef DEBUG +//{ +//WriteLogMsg("Exception: GetPolyEnd(uint16). poly=%u, numPolys=%u\xD\xA", poly, numPolys); +//#endif +// throw GP_OUT_OF_RANGE; +//#ifdef DEBUG +//} +//#endif + + IPoint centroid; // Initializes to (0, 0) + uint16 numPointsInPoly = GetNumPoints(poly); + + for(uint16 i=GetPolyStart(poly); i<=GetPolyEnd(poly); i++) + { + centroid.x += x[i]; + centroid.y += y[i]; + } + + centroid.x /= numPointsInPoly; + centroid.y /= numPointsInPoly; + + return centroid; +} + + +void GlyphPoints::RotatePolyAroundCentroid(const int16 poly, const double angle) +{ + if (poly >= numPolys) + return; + + IPoint centroid = GetPolyCentroid(poly); + + for(uint16 i=GetPolyStart(poly); i<=GetPolyEnd(poly); i++) + { + IPoint rotated = RotatePoint(angle, IPoint(x[i], y[i]), centroid); + x[i] = rotated.x; + y[i] = rotated.y; + } +} + + +void GlyphPoints::InvertPolyDrawSequence(const uint16 poly) +{ + if (poly >= numPolys) + throw GP_OUT_OF_RANGE; + + uint16 pointNum1 = GetPolyStart(poly); + uint16 pointNum2 = GetPolyEnd(poly); + + // Algorithm: Step through points in the polygon, swapping 1st and last, then + // 2nd and (last - 1), 3rd and (last - 2), etc. We only do this for half the + // points, as doing it for all would undo the swapping we did in the 1st half. + for(uint16 i=0; ipts; + fprintf(file, "TTEGLYPH V1.0\n"); + fprintf(file, "POINTS %u\n", numPoints); + + for(int i=0; i