npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pixi-app

v0.1.2

Published

PIXI.js base App

Downloads

1

Readme

PIXI app


  • Will setup a stage with predefined size, and scale this stage to be "contain"ed in the canvas. This way, you will have a fixed coordinate system no matter what canvas/window size you use.
  • Can automatically grow to window-size and inject itself to the DOM.
  • You can add "layers" or "components".
  • The pixi-app can show one or more layers using show()
  • Layers have a lifecyle to manage resource loading and enter/leave animation.

USAGE

  var App = require('pixi-app');

  // Create app
  var app = new App({
    dpi: 1 // dpi (canvas pixels to screen pixels)
    canvasWidth: window.innerWidth,
    canvasHeight: window.innerHeight,
    stageWidth: 1920,
    stageHeight: 1080, // stage will be scaled to be "contain"ed in canvas

    // define layers
    layers: {
      id: {
        load: {
          name: url
        },
        setup: function(opts) { return new PIXI.Sprite() },
        enter: function(opts) { },
        laeve: function(opts) { }
      }
    },

    // define "route" - a shortcut for showing multiple layers
    routes: {
      name: [id,id,id]
    },

    // backgroudd color
    backgroundColor: 0x000000,
    // inject canvas to DOM when domready
    inject: true,
    // show route or layerIds when initialized
    show: []

    // file -- will a resource URL before passing it to the pixi resource loader
    file: function(url) { return url }
  });

  // Add layers
  app.add(id,{
     id: id //(set by app)
     element: null //(set by app)
     load: {
        name: url             // loaded by PIXI
     },      
     setup: function(opts){ } // setup pixi layer, return pixi displayobject or promise
     enter: function(opts){ } // enter animation, can return promise
     leave: function(opts){ } // leave animation, can return promise
     // all functions are bound to the app instance.
  })

  // remove a layer
  app.remove(id)

  // show layer(s)
  app.show([id,id,id,...])

  // render on next rAF
  app.render()

  // render NOW
  app.render(true)

  // Set state or emit an event
  app.set('stuff',{})
  app.emit('stuff',{})

  // Get state (sync)
  app.get('stuff')

  // Listen to state changes or events
  app.on('stuff', function(){ })
  app.once('stuff', function(){ })
  app.off('stuff', function(){ })

Lifecycle

PIXI App manages layers for you.

When showing a layer, it goes through a lifecycle that allows you to control loading of resources and enter/leave animations.

  1. leave - leave old layers, wait for promises to resolve
  2. load - load PIXI resources, wait for resources to be loaded
  3. setup - run setup function (if layer.element is not yet set)
  4. enter - run enter animation, wait for promises to resolve

These steps can be defined in the layer definition object (see app.add), or you can listen to them as events (app.on('leave',function(){})). If you pass a promise in the event-handler, the app will with for the promise to resolve.