perspectiveViewerElementFromNums static method

ViewerElement<List<Point<num>>> perspectiveViewerElementFromNums(
  1. List? perspective, [
  2. Color? color
])

Converts a List<num> (pairs of perspective points) to ViewerElement< List<Point<num>> >.

Implementation

static ViewerElement<List<Point<num>>> perspectiveViewerElementFromNums(
    List? perspective,
    [Color? color]) {
  if (perspective == null) {
    return perspectiveViewerElement(null, color);
  }

  var perspectiveNums = parseNumsFromList(perspective);

  // ignore: omit_local_variable_types
  List<Point<num>> points = [];

  for (var i = 1; i < perspectiveNums.length; i += 2) {
    var x = perspectiveNums[i - 1];
    var y = perspectiveNums[i];
    points.add(Point(x, y));
  }

  return perspectiveViewerElement(points, color);
}