globalVertices method
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,
size,
scale,
angle,
])) {
for (var i = 0; i < _vertices.length; i++) {
final vertex = _vertices[i];
_globalVertices[i]
..setFrom(vertex)
..multiply(scale)
..add(position)
..rotate(angle, center: position);
}
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(), size.clone(), scale.clone(), angle],
);
}
return _cachedGlobalVertices.value!;
}