mwg API
    Preparing search index...

    Class Grid

    A column/row grid whose tracks are size or grow, the data-driven counterpart to GUI2's [grid]. Fixed tracks take their size; the rest of the space is divided between the grow tracks in proportion to their weight, so a sidebar can be size: 200 and the content grow: 1 without either side knowing the window's width.

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

    const grid = new Grid({ columns: [{ size: 200 }, { grow: 1 }], rows: [{ grow: 1 }], gap: 8 });
    const cell = grid.rect(0, 1, { x: 0, y: 0, width: 800, height: 600 });
    console.log(cell); // the content column: x 208, width 592
    Index
    • the resolved pixel width of each column for a given total width

      Parameters

      • totalWidth: number

      Returns number[]

    • The rectangle of a cell, spanning columnSpan columns and rowSpan rows. Out-of-range cells resolve to a zero-sized rect at the far edge rather than throwing, so a caller walking a changing table never has to bounds-check first.

      Parameters

      • row: number
      • column: number
      • bounds: LayoutRect
      • options: { columnSpan?: number; rowSpan?: number } = {}

      Returns LayoutRect

    • the resolved pixel height of each row for a given total height

      Parameters

      • totalHeight: number

      Returns number[]