scaleHandleToAnchorDistances method

void scaleHandleToAnchorDistances(
  1. double factor
)

Implementation

void scaleHandleToAnchorDistances(double factor) {
  for (var submob in getVectorizedFamily()) {
    if (submob.getNumPoints() < nPointsPerCurve) {
      continue;
    }

    var anchorsAndHandles = submob.getAnchorsAndHandles();
    var a1 =
        Array(values: [for (var vec in anchorsAndHandles[0]) vec.toList()]);
    var h1 =
        Array(values: [for (var vec in anchorsAndHandles[1]) vec.toList()]);
    var h2 =
        Array(values: [for (var vec in anchorsAndHandles[2]) vec.toList()]);
    var a2 =
        Array(values: [for (var vec in anchorsAndHandles[3]) vec.toList()]);

    var a1ToH1 = h1 - a1;
    var a2ToH2 = h2 - a2;

    var newH1 = [
      for (var row
          in (a1 + Array.fromValue(factor, shape: a1ToH1.shape) * a1ToH1)
              .values)
        Vector3(row[0], row[1], row[2])
    ];
    var newH2 = [
      for (var row
          in (a2 + Array.fromValue(factor, shape: a2ToH2.shape) * a2ToH2)
              .values)
        Vector3(row[0], row[1], row[2])
    ];

    submob.setAnchorsAndHandles(
        anchorsAndHandles[0], newH1, newH2, anchorsAndHandles[3]);
  }
}