// Initial move...
// If last point is on curve then move to it, otherwise move to first point...
- int x, y;
-
- if (gp->GetOnCurve(poly, gp->GetPrev(poly, 0)))
- x = gp->GetX(poly, gp->GetPrev(poly, 0)),
- y = gp->GetY(poly, gp->GetPrev(poly, 0));
- else
+//NOTE: This is basically doing the below for i=-1.
+// Find some way to integrate this crap.
+/*
+Could do in pairs: get i and i+1, connect them depending on whether the pair
+is a line or a curve.
+4 cases: on to on (line),
+ on to off (begin curve),
+ off to on (end curve),
+ off to off (begin curve)
+*/
+#if 1
+ for(int i=0; i<gp->GetNumPoints(poly); i++)
{
- x = (int)gp->GetX(poly, 0), y = (int)gp->GetY(poly, 0);
+ if (i == 0)
+ {
+ IPoint pt = (gp->GetOnCurve(poly, 0)
+ ? gp->GetPoint(poly, 0) : (gp->GetPrevOnCurve(poly, 0)
+ ? gp->GetPrevPoint(poly, 0) : gp->GetMidpointToPrev(poly, 0)));
+ path->moveTo(pt.x, pt.y);
+ }
- if (!gp->GetOnCurve(poly, 0))
+ if (gp->GetOnCurve(poly, i) && gp->GetNextOnCurve(poly, i))
{
- IPoint pt = gp->GetMidpointToPrev(poly, 0);
- x = pt.x, y = pt.y;
+ // Handle lines...
+ path->lineTo(gp->GetNextX(poly, i), gp->GetNextY(poly, i));
+ }
+ else
+ {
+ // Skip point if it's on curve (start of curve--it's already
+ // been plotted so we don't care about it...
+ if (gp->GetOnCurve(poly, i))
+ i++;
+
+ // We may have moved past the end; if not, handle curve
+ if (i < gp->GetNumPoints(poly))
+ {
+ // Handle curves...
+ IPoint pt = (gp->GetNextOnCurve(poly, i)
+ ? gp->GetNextPoint(poly, i) : gp->GetMidpointToNext(poly, i));
+
+ path->quadTo(gp->GetX(poly, i), gp->GetY(poly, i), pt.x, pt.y);
+ }
}
}
+#else
+ IPoint pt;
- path->moveTo(x, y);
+ if (gp->GetPrevOnCurve(poly, 0))
+ pt = gp->GetPrevPoint(poly, 0);
+ else
+ pt = (gp->GetOnCurve(poly, 0)
+ ? gp->GetPoint(poly, 0) : gp->GetMidpointToPrev(poly, 0));
+
+ path->moveTo(pt.x, pt.y);
for(int i=0; i<gp->GetNumPoints(poly); i++)
{
if (gp->GetOnCurve(poly, i))
- {
-// p.drawLine(x, y, gp->GetX(poly, i), gp->GetY(poly, i));
- x = (int)gp->GetX(poly, i), y = (int)gp->GetY(poly, i);
- path->lineTo(x, y);
- }
+ path->lineTo(gp->GetX(poly, i), gp->GetY(poly, i));
else
{
- IPoint pt = (gp->GetOnCurve(poly, gp->GetNext(poly, i)) ? gp->GetNextPoint(poly, i) : gp->GetMidpointToNext(poly, i));
+ pt = (gp->GetNextOnCurve(poly, i)
+ ? gp->GetNextPoint(poly, i) : gp->GetMidpointToNext(poly, i));
path->quadTo(gp->GetX(poly, i), gp->GetY(poly, i), pt.x, pt.y);
- x = pt.x, y = pt.y;
// If following point is on curve, move past it
- if (gp->GetOnCurve(poly, gp->GetNext(poly, i)))
+ if (gp->GetNextOnCurve(poly, i))
i++;
}
}
+#endif
path->closeSubpath();
}
QSize paintSize = size();
p.translate(0, paintSize.height());
-float extraX = 0.0f, extraY = 0.0f;
-float xConvFac = (float)paintSize.width() / rect.width();
-float yConvFac = (float)paintSize.height() / rect.height();
+ float extraX = 0.0f, extraY = 0.0f;
+ float xConvFac = (float)paintSize.width() / rect.width();
+ float yConvFac = (float)paintSize.height() / rect.height();
-// if (((float)paintSize.width() / rect.width()) > ((float)paintSize.height() / rect.height()))
if (xConvFac > yConvFac)
{
// height is limiting factor
else
{
// width is limiting factor
-// p.scale((float)paintSize.width() / rect.width(), -(float)paintSize.width() / rect.height());
- p.scale((float)paintSize.width() / rect.width(), -(float)paintSize.width() / rect.width());
-extraY = (rect.width() / (float)paintSize.width()) * (float)paintSize.height();// / 2.0f;
-extraY = extraY - rect.height();
-extraY /= 2.0f;
+ p.scale(xConvFac, -xConvFac);
+//extraY = (rect.width() / (float)paintSize.width()) * (float)paintSize.height();
+//extraY = (extraY - rect.height()) / 2.0f;
+ extraY = (((float)paintSize.height() / xConvFac) - rect.height()) / 2.0f;
}
p.translate(-rect.x() + extraX, -rect.y() + extraY);