]> Shamusworld >> Repos - ttedit/blobdiff - src/glyphpoints.cpp
Minor changes: Supply a reasonable default epsilon to vector::zero() and
[ttedit] / src / glyphpoints.cpp
index d0402f6fe041ddc800a29b03db00a24c53d9439f..0fc62f3cd40af42b8bf2603bc8d5aad7330e2bb2 100755 (executable)
@@ -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<numPolys; i++)
@@ -368,6 +368,11 @@ WriteLogMsg("Exception: GetX(uint16, uint16). poly= %u, pt=%u, numPoints=%u\xD\x
        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))
@@ -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));
+}