samplePaths static method
This method is responsible for sampling both the paths. It generates a SampledPathData object containing all the details required for the morph animation.
Implementation
static SampledPathData samplePaths(Path path1, Path path2,
{double precision = 0.01}) {
var data = SampledPathData();
var k = 0;
path1.computeMetrics().forEach((metric) {
for (var i = 0.0; i < 1.1; i += precision) {
Tangent? tangent = metric.getTangentForOffset(metric.length * i);
if (tangent == null) continue;
Offset position = tangent.position;
data.points1.add(position);
data.shiftedPoints.add(position);
}
});
path2.computeMetrics().forEach((metric) {
data.endIndices.add(k);
for (var i = 0.0; i < 1.1; i += precision) {
Tangent? tangent = metric.getTangentForOffset(metric.length * i);
if (tangent == null) continue;
k += 1;
data.points2.add(tangent.position);
}
});
return data;
}