area static method

double area(
  1. List<Vector?> contour
)

contour -- 2D polygon. An array of Vector2()

Calculate area of a ( 2D ) contour polygon.

Implementation

static double area(List<Vector?> contour) {
  final n = contour.length;
  double a = 0.0;

  for (int p = n - 1, q = 0; q < n; p = q++) {
    if(contour[p] != null){
      a += contour[p]!.x * contour[q]!.y - contour[q]!.x * contour[p]!.y;
    }
  }

  return a * 0.5;
}