importData method

void importData(
  1. Map data
)

Expects data from toMap.

Implementation

void importData(Map data) {
  final list = <CubicPath>[];

  final bounds = Size(data['bounds']['width'], data['bounds']['height']);
  final paths = data['paths'];
  final threshold = data['threshold'];
  final smoothRatio = data['smoothRatio'];
  final velocityRange = data['velocityRange'];

  for (final path in paths) {
    final List points = List.from(path);

    final cp = CubicPath(
      threshold: threshold,
      smoothRatio: smoothRatio,
    ).._maxVelocity = velocityRange;

    cp.begin(OffsetPoint.fromMap(points[0]));
    points.skip(1).forEach((element) => cp.add(OffsetPoint.fromMap(element)));
    cp.end();

    list.add(cp);
  }

  importPath(list, bounds);
}