toOtherAnchorPosition method

Vector2 toOtherAnchorPosition(
  1. Vector2 position,
  2. Anchor otherAnchor,
  3. Vector2 size
)

Take your position position that is on this anchor and give back what that position it would be on in anchor otherAnchor with a size of size.

Implementation

Vector2 toOtherAnchorPosition(
  Vector2 position,
  Anchor otherAnchor,
  Vector2 size,
) {
  if (this == otherAnchor) {
    return position;
  } else {
    return position +
        ((otherAnchor.toVector2() - toVector2())..multiply(size));
  }
}