X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fglyphpoints.cpp;h=a11b09ca3c5b82ba0221a832ab3052eefefda0cd;hb=faaae13292af283e277b0d1480aad54a6e4a2dd6;hp=05edc828d791d44bba987e683b0ed935f1c1b858;hpb=360d040a4727383cc8e78d0b8a3c8151c27d26fc;p=ttedit diff --git a/src/glyphpoints.cpp b/src/glyphpoints.cpp index 05edc82..a11b09c 100755 --- a/src/glyphpoints.cpp +++ b/src/glyphpoints.cpp @@ -437,7 +437,7 @@ int GlyphPoints::GetNextY(uint16 poly, uint16 pt) IPoint GlyphPoints::GetPoint(uint16 poly, uint16 pt) { - return IPoint(GetX(poly, pt), GetY(poly, pt)); + return IPoint(GetX(poly, pt), GetY(poly, pt), GetOnCurve(poly, pt)); } @@ -446,7 +446,7 @@ IPoint GlyphPoints::GetPoint(uint16 pointNumber) if (pointNumber > numPoints) throw GP_OUT_OF_RANGE; - return IPoint(x[pointNumber], y[pointNumber]); + return IPoint(x[pointNumber], y[pointNumber], onCurve[pointNumber]); } @@ -580,6 +580,22 @@ WriteLogMsg("Exception: SetOnCurve(uint16, bool). pt=%u, numPoints=%u\xD\xA", pt } +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 @@ -808,8 +824,10 @@ IPoint GlyphPoints::GetPolyCentroid(const int16 poly) { // We should throw an exception here, but meh // (this actually short circuits the exception handling in all the GetPolyXXX() functions) + // [now we do!] if (poly >= numPolys) - return IPoint(0, 0); + throw GP_OUT_OF_RANGE; +// return IPoint(0, 0); // if (poly >= numPolys) //#ifdef DEBUG @@ -853,6 +871,27 @@ void GlyphPoints::RotatePolyAroundCentroid(const int16 poly, const double angle) } +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; i