]> Shamusworld >> Repos - ttedit/blobdiff - src/glyphpoints.cpp
Fixed character window to render the main window's points properly,
[ttedit] / src / glyphpoints.cpp
index d0402f6fe041ddc800a29b03db00a24c53d9439f..d7ce0d5b19d082d629c28aa9f8458142830402e2 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++)
@@ -579,3 +579,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));
+}