toOtherAnchorPosition method

Vector2 toOtherAnchorPosition(
  1. Vector2 position,
  2. Anchor otherAnchor,
  3. Vector2 size, {
  4. Vector2? out,
})

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, {
  Vector2? out,
}) {
  if (this == otherAnchor) {
    return position;
  } else {
    return (out ?? Vector2.zero())
      ..setValues(otherAnchor.x - x, otherAnchor.y - y)
      ..multiply(size)
      ..add(position);
  }
}