mwg API
    Preparing search index...

    Function resolveAnchor

    • Places a size-shaped child against the bounds - the anchor half of a data-driven shell, the part GUI2 spells as [cell] anchoring a widget inside its slot.

      A fill anchor takes the bounds (minus margins) whole; every other anchor lines the child up on the named edge and then applies the offsets, so { anchor: 'bottom-right', offsetX: -8 } pins a button eight pixels in from the bottom-right corner.

      Parameters

      Returns LayoutRect

      import { resolveAnchor } from '@datamoc/mw_games/two-d/ui';

      const bounds = { x: 0, y: 0, width: 800, height: 600 };
      console.log(resolveAnchor({ anchor: 'bottom-right', width: 100, height: 30, margin: 10 }, bounds));
      // { x: 690, y: 560, width: 100, height: 30 }