npm

pixihook
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

PixiHook

A react hook library for the 2D engine PixiJs

Installing

Using npm:

$ npm install pixihook

Using yarn:

$ yarn add pixihook

Example

const Component = () => {
    const { app, PIXI } = usePixi({
        width: window.innerWidth,
        height: window.innerHeight,
        containerId: 'pixiContainer',
        backgroundColor: 0x404142,
        antialias: true
    });

    const graphics = new PIXI.Graphics();

    const setup = () => {
        graphics.x = 0;
        graphics.y = 0;
    }

    const drawGrid = () => {
        graphics.lineStyle(2, 0xaaaaaa);

        for (let i = 0; i < 100; i++) {
            graphics.moveTo(0, i * 80);
            graphics.lineTo(window.innerWidth, i * 80);
        }

        for (let i = 0; i < 100; i++) {
            graphics.moveTo(i * 80, 0);
            graphics.lineTo(i * 80, window.innerHeight);
        }
    }

    setup();

    app.ticker.add(() => {
        graphics.clear();
        drawGrid();  
    });

    app.stage.addChild(graphics);

    return (
        <div>
            <h1 style={{ textAlign: 'center' }}>Hello Pixi</h1>
            <div id="pixiContainer" />
        </div>
    )
}

Result: Example

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i pixihook

Weekly Downloads

0

Version

1.0.3

License

MIT

Unpacked Size

7.49 kB

Total Files

9

Last publish

Collaborators

  • shadyzpop