scaled method

  1. @override
GPath scaled(
  1. double scale
)
override

Scaled version of this GShape.

Implementation

@override
GPath scaled(double scale) {
  var pathPoints2 = pathPoints.toList();
  final length = pathPoints2.length;

  for (var i = 0; i < length; ++i) {
    var e = pathPoints2[i];

    if (e is num) {
      var x1 = e;
      var y1 = pathPoints2[i + 1] as num;

      pathPoints2[i] = x1 * scale;
      pathPoints2[++i] = y1 * scale;
    } else if (e is Point) {
      pathPoints2[i] = e.scale(scale, scale);
    } else if (e is List<num>) {
      var cubic = e.toList(growable: false);
      assert(cubic.length == 6);

      var x1 = cubic[0];
      var y1 = cubic[1];

      var x2 = cubic[2];
      var y2 = cubic[3];

      var x3 = cubic[4];
      var y3 = cubic[5];

      cubic[0] = x1 * scale;
      cubic[1] = y1 * scale;

      cubic[2] = x2 * scale;
      cubic[3] = y2 * scale;

      cubic[4] = x3 * scale;
      cubic[5] = y3 * scale;

      pathPoints2[i] = cubic;
    }
  }

  return GPath(pathPoints2,
      strokeSize: strokeSize?.scaled(scale),
      strokeColor: strokeColor,
      fillColor: fillColor,
      closePath: closePath);
}