decompactImplicitPoints method
void
decompactImplicitPoints()
Decompacts implicit points of quadratic curves (midpoints and end points)
Implementation
void decompactImplicitPoints() {
if (!hasCompactCurves) {
return;
}
if (!hasQuadCurves) {
throw UnsupportedError('Only quadratic curves supported');
}
// Starting with 2, because first point can't be a CP and we need 2 of them
for (var i = 2; i < pointList.length; i++) {
// Two control points in a row
if (!isOnCurveList[i - 1] && !isOnCurveList[i]) {
final c0 = pointList[i - 1];
final c1 = pointList[i];
// Calculating midpoint
final midpoint = (c0 + c1) * .5;
// Adding midpoint to the list and moving to the next point
pointList.insert(i, midpoint);
isOnCurveList.insert(i, true);
i++;
}
}
// Last point is CP - duplicating start point
if (!isOnCurveList.last) {
isOnCurveList.add(true);
pointList.add(pointList.first);
}
_hasCompactCurves = false;
}