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 🙏

© 2025 – Pkg Stats / Ryan Hefner

shader-art

v1.3.0

Published

A web component running WebGL shaders

Readme

<shader-art> component

The <shader-art> component is a web component that creates a WebGL canvas, running a shader animation.

Getting started

npm i shader-art

JavaScript

import { ShaderArt } from 'https://cdn.skypack.dev/shader-art';

ShaderArt.register();

CSS

You can style your shader-element according to your needs. Just provide a display: block (default would be display: inline) and specify a width and height according to your needs.

shader-art {
  display: block;
  width: 100vmin;
  height: 100vmin;
}

HTML

The HTML structure of a shader-art component looks like this:

<shader-art autoplay>
  <script type="vert">
    precision highp float;
    attribute vec4 position;
    void main() {
      gl_Position = position;
    }
  </script>

  <script type="frag">
    precision highp float;
    uniform float time;
    uniform vec2 resolution;
    void main() {
      float t = time * 1e-3;
      vec2 p = gl_FragCoord.xy / resolution;
      vec3 color = vec3(1.0, sin(p.x + t * 2.), sin(p.y + t));
      gl_FragColor=vec4(color, 1.0);
    }
  </script>
</shader-art>

Using WebGL2

Provide the #version 300 es pragma inside your fragment and vertex shader code.

<shader-art> attributes

  • autoplay immediately starts playing
  • play-state="running|stopped" get/set current play-state (it is set to running automatically when autoplay is enabled)
  • regardless of the play-state the component respects the user's prefers-reduced-motion settings
  • dpr="auto|number" get/set device pixel ratio (default is "auto", which uses window.devicePixelRatio)

Provided uniforms

  • uniform float time: number of ticks passed
  • uniform vec2 resolution: resolution of the canvas

Adding textures

Texture support can be added via a TexturePlugin.

You can load the texture plugin by importing the TexturePlugin and adding it to the ShaderArt.register call like this:

import { TexturePlugin } from 'https://cdn.skypack.dev/shader-art/plugins/texture-plugin';

ShaderArt.register([() => new TexturePlugin()]);

Building your own plugins

You can build your own plugins by implementing this interface:

export interface ShaderArtPlugin {
  name: string;
  setup(
    hostElement: HTMLElement,
    gl: WebGLRenderingContext | WebGL2RenderingContext,
    program: WebGLProgram,
    canvas: HTMLCanvasElement
  ): void | Promise<void>;
  dispose(): void;
}

If the setup method returns a promise, the shader-art component will wait until the promise resolves.