X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fglyphpoints.cpp;h=0fc62f3cd40af42b8bf2603bc8d5aad7330e2bb2;hb=7169af5d07be6e496cef0ac88d0e13647041d198;hp=d0402f6fe041ddc800a29b03db00a24c53d9439f;hpb=c84263bb8b0d16e4c6da49aa0b7d0bc904ae02b1;p=ttedit diff --git a/src/glyphpoints.cpp b/src/glyphpoints.cpp index d0402f6..0fc62f3 100755 --- a/src/glyphpoints.cpp +++ b/src/glyphpoints.cpp @@ -230,7 +230,7 @@ void GlyphPoints::InsertPoint(uint16 pt, int xx, int yy, bool oc) totX[pt] = xx, totY[pt] = yy, totOnCurve[pt] = oc; -//A way to fix the kludge in GetPoly() would be to put a check here to see if +//A way to fix the kludge in GetPoly() would be to put a check here to see if //we're adding to the end of the structure: [DONE, below] int polyInsert = (pt == numPoints ? numPolys - 1 : GetPoly(pt)); for(int i=polyInsert; i= GetNumPoints(poly)) @@ -383,6 +388,16 @@ WriteLogMsg("Exception: GetY(uint16, uint16). poly= %u, pt=%u, numPoints=%u\xD\x 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)); +} + bool GlyphPoints::GetOnCurve(uint16 poly, uint16 pt) { if (pt >= GetNumPoints(poly)) @@ -398,6 +413,16 @@ WriteLogMsg("Exception: GetOnCurve(uint16, uint16). poly= %u, pt=%u, numPoints=% 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::GetPolyEnd(uint16 poly) { if (poly >= numPolys) @@ -579,3 +604,36 @@ void GlyphPoints::AddNewPolyAtEnd(void) polyEnd = newPolyEnd; } +IPoint GlyphPoints::GetMidpointToPrev(uint16 poly, uint16 pt) +{ + uint16 prev = GetPrev(poly, pt); + + int32 x1 = GetX(poly, pt), y1 = GetY(poly, pt); + int32 x2 = GetX(poly, prev), y2 = GetY(poly, prev); + + return IPoint((x1 + x2) / 2.0f, (y1 + y2) / 2.0f); +} + +IPoint GlyphPoints::GetMidpointToNext(uint16 poly, uint16 pt) +{ + uint16 next = GetNext(poly, pt); + + int32 x1 = GetX(poly, pt), y1 = GetY(poly, pt); + int32 x2 = GetX(poly, next), y2 = GetY(poly, next); + + return IPoint((x1 + x2) / 2.0f, (y1 + y2) / 2.0f); +} + +IPoint GlyphPoints::GetPrevPoint(uint16 poly, uint16 pt) +{ + uint16 prevPt = GetPrev(poly, pt); + + return IPoint(GetX(poly, prevPt), GetY(poly, prevPt)); +} + +IPoint GlyphPoints::GetNextPoint(uint16 poly, uint16 pt) +{ + uint16 nextPt = GetNext(poly, pt); + + return IPoint(GetX(poly, nextPt), GetY(poly, nextPt)); +}