isClockwise property

bool get isClockwise

Whether vertices are in clockwise winding order

Based on signed area: negative = clockwise, positive = counter-clockwise.

Implementation

bool get isClockwise {
  double sum = 0;
  final n = vertices.length;
  for (var i = 0; i < n; i++) {
    final nextI = (i + 1) % n;
    sum += vertices[i].x * vertices[nextI].y -
        vertices[nextI].x * vertices[i].y;
  }
  return sum < 0;
}