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

glsl2img

v0.2.0

Published

GLSL to image converter

Downloads

16

Readme

glsl2img

Build Status NPM Version License Coverage Status

CLI tool to render fragment shaders into PNG images.
Thanks to https://gist.github.com/bsergean/6780d7cc0cabb1b4d6c8.

Install

npm install -g glsl2img

Usage

This package includes 2 CLI commands: glsl2png and glsl2gif.

glsl2png

glsl2png -h shows the help:

  Usage
  $ glsl2png <input>

  Options
    --out, -o   Output file name. Default: out.png
    --size, -s  Specify image size in wxh format. Default: 600x600
    --time, -t  Specify time to pass the shader as uniform. Default: 0

  Examples
    $ glsl2png foo.frag -s 720x540 -o image.png

Examples

Assume we have metaball.frag like this:

#ifdef GL_ES
precision mediump float;
#endif

uniform float time;
uniform vec2 resolution;

void main (void) {
    vec2 position = gl_FragCoord.xy / resolution.xy;

    float d = sin(time) * 0.2;

    float dist1 = pow(max(1.0 - distance(position, vec2(0.5 + d, 0.5)) * 5.0, 0.0), 2.0);
    float dist2 = pow(max(1.0 - distance(position, vec2(0.5 - d, 0.5)) * 5.0, 0.0), 2.0);

    float c = smoothstep(0.3, 0.301, dist1 + dist2);
    gl_FragColor = vec4(c, 0, c, 1.0);
}

then glsl2png metaball.frag -o out.png gives following image.

out

We can also specify time value via -t option.
Here is the result of glsl2png metaball.frag -o out2.png -t 10.

out2

glsl2gif

glsl2gif -h shows the help:

  Usage
  $ glsl2gif <input>

  Options
    --out, -o     Output file name. Default: out.gif
    --rate, -r    Frames per second. Default: 15
    --length, -l  The length of GIF animation. Default: 1 (second)
    --size, -s    Specify image size in wxh format. Default: 600x600

  Examples
    $ glsl2gif foo.frag -s 720x540 -o image.gif

Examples

glsl2gif metaball.frag -r 30 -l 3.0 gives following image.

out.gif

LICENSE

MIT