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 🙏

© 2026 – Pkg Stats / Ryan Hefner

shader-box

v1.2.2-b

Published

the easiest way to render a simple 1x1 frag shader.

Readme

ShaderBox

npm install shader-box

live example

An easy way to render a simple frag shader on a 4 vertex triangle strip, no dependencies. Great for initial/concept development of different shaders, or showing off a collection of shaders on one canvas!

Import it as a module or use the script tag with window.ShaderBox

Example

import {Shader,Box} from 'shader-box'

var box = new Box({
  canvas: window.my_canvas, //canvas element to get context from
  resize: true, //auto resize viewport on window.resize
  clearColor: [0, 0, 0, 1], //clear color
  grid: [2,1], //set a cutom size for columns and rows (x,y) of a grid if you want to display more 
  than one shader like in this example.
  context: {  // context options passed to .getContext
    antialias: true,
    depth: false
  }
});

//create a shader
var shaderA = new Shader({
  source: frag_shader, //you can use webpack and require your shaders easy with a glsl or raw loader, look in the webpack.config.js for more
  uniforms: {
    iTime: {
      type: '1f',
      value: 0.4
    }
  }
});

//create another shader
var shaderB = new Shader({
  source: frag_shader2, //you can use webpack and require your shaders easy with a glsl or raw loader, look in the webpack.config.js for more
  textureUrl: './star.jpeg',
  uv: [1,1], //set the uv to match the width/height ratio of the star, in this case the image is square.
  uniforms: {
    pos: {
      type: '2fv', // uniform type. creates a function like `set = @gl["uniform"+type].bind(@gl)`
      value: [0.4, 0.4]
    },
    iTime: {
      type: '1f',
      value: 0.4
    }
  }
});

//add the shaders.
box.add(shaderA).add(shaderB);

//draw it!
var tick = function(t){
  requestAnimationFrame(tick)

  //update the uniforms.
  shaderA.uniforms.iTime.value = t 
  shaderB.uniforms.pos.value[0] = 0.5

  //clear and draw
  box
    .clear()
    .draw(shaderA) //draw a shader
    .draw(shaderB) //draw a shader
  
  box.focus = 0  //make the first shader fullscreen.
}

tick(0);

Uniforms

varying vec2 v_uv; //gl uv position from 0 to 1, starting top left and ending at bottom right.
uniform sampler2D u_texture;

Box Options

  • canvas domElement (required) canvas element
  • resize true update the viewport on window resize
  • clearColor [0,0,0,0] : 4 length array for the clearColor
  • context {} : canvas.getContext 2nd parameter object. includes settings such as antialias and depth.
  • grid [1,1] : columns and rows. change this when you want to show multiple shaders on one screen.

Shader Options

  • source String (required) fragment shader string.
  • uv [1.0,1.0] : aspect/size ratio for width and height of the UV.
  • uniforms {} uniform format is as follows:
  • my_uniform_name: {
      type: '2fv', // uniform type. creates a function from this string `set = @gl["uniform"+type].bind(@gl)`
      value: [0.4, 0.4]
    }
  • textureUrl: String set the url of a texture you want to load. if your texture is not 1:1, you need to set the uv so that it matches the ratio of the texture.

Box Methods

  • .add Shader add and initalize a shader assigning it to a position on the grid.
  • .clear clear the canvas.
  • .draw Shader draw a shader.
  • .focus Integer when rendering more than one shader, you can set the focus to a particular index on the grid. index positions are incremented whenever a shader is added.


This library uses ES6 classes and is compiled from coffeescript. you can find the source files in the src folder/ To run webpack-dev-server with example use npm i && npm run dev

todos

  • multiple buffers for image transitions, etc...
  • clean up code