makeVertexDeform method

void makeVertexDeform()

Implementation

void makeVertexDeform() {
  if (vertexDeform != null) {
    return;
  }
  int length = points.fold<int>(0, (int previous, PathPoint point) {
    return previous + 2 + (point.pointType == PointType.straight ? 1 : 4);
  });
  Float32List vertices = Float32List(length);
  int readIdx = 0;
  for (final PathPoint point in points) {
    vertices[readIdx++] = point.translation[0];
    vertices[readIdx++] = point.translation[1];
    if (point.pointType == PointType.straight) {
      // radius
      vertices[readIdx++] = (point as StraightPathPoint).radius;
    } else {
      // in/out
      CubicPathPoint cubicPoint = point as CubicPathPoint;
      vertices[readIdx++] = cubicPoint.inPoint[0];
      vertices[readIdx++] = cubicPoint.inPoint[1];
      vertices[readIdx++] = cubicPoint.outPoint[0];
      vertices[readIdx++] = cubicPoint.outPoint[1];
    }
  }
  vertexDeform = vertices;
}