mwg API
    Preparing search index...

    Class NinePatch

    A panel that can be resized without distorting its frame.

    The texture is cut into nine: four corners that never stretch, four edges that stretch along one axis, and a middle that fills. It is what makes one small window texture serve every window in the game, at any size.

    Pixi has this built in; the wrapper exists so that a border can be given as one number, which is the case for almost every panel, and so that resizing reads the same as it does on the framework's other widgets.

    import { NinePatch } from '@datamoc/mw_games/two-d/ui';
    import type { Texture2D } from '@datamoc/mw_games/two-d/render';

    declare const panelTexture: Texture2D;

    const panel = new NinePatch(panelTexture, { border: 8 });
    panel.resize(200, 120);
    console.log(panel.border); // { left: 8, top: 8, right: 8, bottom: 8 }

    panel.alpha = 0.6; // fading the panel needs no extra API, unlike width/height/tint above

    Hierarchy

    • Container
      • NinePatch
    Index
    • get border(): { bottom: number; left: number; right: number; top: number }

      the border widths, which a window needs to know to inset its contents

      Returns { bottom: number; left: number; right: number; top: number }