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));
}
if (pointNumber > numPoints)
throw GP_OUT_OF_RANGE;
- return IPoint(x[pointNumber], y[pointNumber]);
+ return IPoint(x[pointNumber], y[pointNumber], onCurve[pointNumber]);
}
}
+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
{
// 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
}
+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<GetNumPoints(poly)/2; i++)
+ {
+ IPoint point1 = GetPoint(pointNum1 + i);
+ IPoint point2 = GetPoint(pointNum2 - i);
+ SetPoint(pointNum2 - i, point1);
+ SetPoint(pointNum1 + i, point2);
+ }
+}
+
+
// really need to do checking on the results from fscanf...
bool GlyphPoints::LoadGlyphFromFile(FILE * file)
{
for(int i=0; i<numPoints; i++)
{
- fscanf(file, "%d %d %s", &x[i], &y[i], &line);
+ fscanf(file, "%d %d %s", &x[i], &y[i], (char *)&line);
onCurve[i] = (line[0] == 'T' ? true : false);
}