place method

void place(
  1. LayoutItem item,
  2. Vector2 position
)

Implementation

void place(LayoutItem item, Vector2 position) {
  final size = item.size;
  final scale = item.scale;
  final anchor = item.anchor;

  // The anchor offset arrives scaled, in the item's own space. A flipped axis
  // puts its anchor on the opposite edge.
  final anchorX = scale.x < 0 ? anchor.x - 1 : anchor.x;
  final anchorY = scale.y < 0 ? anchor.y - 1 : anchor.y;

  item.position.setValues(
    anchorX * size.x * scale.x + position.x,
    anchorY * size.y * scale.y + position.y,
  );
}