globalVertices method

List<Vector2> globalVertices()

gives back the shape vectors multiplied by the size and scale

Implementation

List<Vector2> globalVertices() {
  final scale = absoluteScale;
  final angle = absoluteAngle;
  final position = absoluteTopLeftPosition;
  if (!_cachedGlobalVertices.isCacheValid<dynamic>(<dynamic>[
    position,
    scale,
    angle,
  ])) {
    var i = 0;
    for (final vertex in vertices) {
      _globalVertices[i]
        ..setFrom(vertex)
        ..multiply(scale)
        ..add(position)
        ..rotate(angle, center: position);
      i++;
    }
    if (scale.y.isNegative || scale.x.isNegative) {
      // Since the list will be clockwise we have to reverse it for it to
      // become counterclockwise.
      _reverseList(_globalVertices);
    }
    _cachedGlobalVertices.updateCache<dynamic>(
      _globalVertices,
      <dynamic>[position.clone(), scale.clone(), angle],
    );
  }
  return _cachedGlobalVertices.value!;
}