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

textmode.filters.js

v1.0.1

Published

Image filters plugin for textmode.js

Downloads

218

Readme

🎨 textmode.filters.js

GPU-accelerated image filters plugin for textmode.js

npm version license PRs Welcome

InstallationUsageFiltersContributing


✨ Features

  • 🚀 GPU-accelerated - All filters run on the GPU via WebGL2 fragment shaders
  • 🎛️ Customizable parameters - Fine-tune each filter to your needs
  • 📦 Lightweight - Minimal footprint, no external dependencies
  • 🤝 Open to contributions - Easy to add your own custom filters!

Installation

npm install textmode.filters.js

Note: Make sure textmode.js is also installed in your project. This add-on declares it as a peer dependency.

You can also use it via CDN:

<!-- ESM -->
<script type="module" src="https://unpkg.com/textmode.js/dist/textmode.esm.js"></script>
<script type="module" src="https://unpkg.com/textmode.filters.js/dist/textmode.filters.esm.js"></script>

<!-- UMD -->
<script src="https://unpkg.com/textmode.js/dist/textmode.umd.js"></script> 
<script src="https://unpkg.com/textmode.filters.js/dist/textmode.filters.umd.js"></script>

Usage

ESM

import { textmode } from 'textmode.js';
import { createFiltersPlugin } from 'textmode.filters.js';

const t = textmode.create({
  width: 800,
  height: 600,
  plugins: [createFiltersPlugin()],
});

t.draw(() => {
  // Apply filters to layers
  t.layers.base.filter('brightness', 1.2);
  t.layers.base.filter('contrast', { amount: 1.5 });

  t.background(0);
  // ... draw something ...
});

UMD

<script src="https://unpkg.com/textmode.js/dist/textmode.umd.js"></script>
<script src="https://unpkg.com/textmode.filters.js/dist/textmode.filters.umd.js"></script>
<script>
  const t = textmode.create({
    plugins: [createFiltersPlugin()],
  });

  t.draw(() => {
    t.layers.base.filter('brightness', 1.3);
  });
</script>

Filters

brightness

Adjust image brightness (1.0 = normal, >1 = brighter, <1 = darker)

Parameters:

  • amount - Brightness multiplier
    Default: 1.0 | Range: 0.0 -

Author: @humanbydefinition


contrast

Adjust image contrast (1.0 = normal, >1 = more contrast, <1 = less)

Parameters:

  • amount - Contrast multiplier
    Default: 1.0 | Range: 0.0 -

Author: @humanbydefinition


hueRotate

Shift colors around the color wheel

Parameters:

  • angle - Rotation angle in degrees
    Default: 0.0 | Range: 0.0 - 360.0

Author: @humanbydefinition


glitch

Digital glitch effect with RGB channel separation, scanlines, and noise

Parameters:

  • amount - Glitch intensity
    Default: 0.0 | Range: 0.0 -

Author: @humanbydefinition


chromaticAberration

RGB color channel separation effect that simulates lens distortion

Parameters:

  • amount - Offset amount in pixels
    Default: 5.0 | Range: 0.0 -
  • direction - Direction of the color separation as [x, y]
    Default: [1.0, 0.0] (horizontal)

Author: @humanbydefinition


pixelate

Reduce image resolution to create a mosaic/pixelated effect

Parameters:

  • pixelSize - Size of each pixel block in pixels
    Default: 4.0 | Range: 1.0 -

Author: @humanbydefinition


Usage examples

// Using a single value (shorthand)
t.layers.base.filter('brightness', 1.5);
t.layers.base.filter('hueRotate', 180);

// Using an options object
t.layers.base.filter('contrast', { amount: 0.8 });
t.layers.base.filter('glitch', { amount: 2.0 });

// Chaining multiple filters in sequence
t.layers.base.filter('brightness', 1.2);
t.layers.base.filter('contrast', 1.3);
t.layers.base.filter('hueRotate', 90);

// Chromatic aberration with custom direction
t.layers.base.filter('chromaticAberration', { amount: 10, direction: [1, 1] });

// Pixelate effect
t.layers.base.filter('pixelate', 8);

Adding custom filters

Want to create your own filter? Check out the Contributing Guide for detailed instructions on how to add new filters to this library!

The basic structure of a filter shader:

#version 300 es
precision highp float;

uniform sampler2D u_texture;    // Input texture
uniform vec2 u_resolution;      // Canvas resolution
uniform float u_yourParam;      // Your custom parameter

in vec2 v_uv;
out vec4 fragColor;

void main() {
    vec4 color = texture(u_texture, v_uv);
    
    // Your filter logic here
    vec3 result = color.rgb; // Modify this!
    
    fragColor = vec4(result, color.a);
}

Contributing

Contributions are welcome and greatly appreciated! 🎉

Whether you want to:

  • 🐛 Report a bug
  • 💡 Suggest a new filter
  • 🔧 Submit a pull request
  • 📖 Improve documentation

Please read our Contributing Guide to get started.

Related projects


↑ Back to Top