explaingit

jakubantalik/img-fx

12TypeScriptAudience · developerComplexity · 2/5ActiveLicenseSetup · easy

TLDR

React component that wraps any card in a WebGL shader canvas which cycles through animated dot or pixel mosaic effects to reveal images from a user-supplied URL pool.

Mindmap

mindmap
  root((img-fx))
    Inputs
      Image URL list
      Preset name
      Theme attribute
      Timing props
    Outputs
      Animated WebGL canvas
      onCycle callback
      Ref handle
    Use Cases
      Card loader effect
      Image reveal hover
      Pixel mosaic backdrop
    Tech Stack
      React
      TypeScript
      ThreeJS
      WebGL
      Vite

Things people build with this

USE CASE 1

Add an animated dot or pixel loader effect to a product card grid

USE CASE 2

Build a hover-to-reveal image gallery with manual trigger and hide controls

USE CASE 3

Drop a WebGL background mosaic onto a hero section with light and dark theming

USE CASE 4

Cycle through a pool of image URLs on a card with shared WebGL context for low overhead

Tech stack

ReactTypeScriptThreeJSWebGLVite

Getting it running

Difficulty · easy Time to first run · 5min

Requires React, ReactDOM, and Three.js as peer dependencies in the host app.

MIT, free to use, modify, and ship in commercial products with attribution.

In plain English

img-fx is a small React library that wraps a card-shaped element in a WebGL canvas and runs an animated shader on top of it. The shader produces what the README calls a generation or loader effect: a moving mosaic of dots or pixels that periodically reveals an image from a pool the user provides. A live demo is hosted at image.jakubantalik.com. Install is npm install img-fx, with React, ReactDOM, and Three.js declared as peer dependencies. The library exports an ImageGeneration component. Wrap any child element in it, set a preset, pass a list of image URLs, and turn on auto-reveal to get the default loop. The README also documents a Vite playground for local development plus build scripts for the library bundle and the demo site. Behaviour is driven by props. preset picks between three bundled shader looks: dots-mechanic, pixels-organic, and pixels-mechanic. theme reads the page's data attribute, class, inline color-scheme, or media query to pick light or dark, and updates live via a MutationObserver. strength is an opacity multiplier. cardBg overrides the card surface colour and keeps the shader's colour-proximity logic in sync. revealDelayRange, revealHoldMs, and revealFadeOutMs control timing. An onCycle callback fires on each phase change. A ref handle exposes manual control. The component accepts a ref whose triggerReveal method runs one full reveal, hold, and hide cycle, with an optional hold: 'manual' mode that pairs with triggerHide. An isImageActive query lets a parent build a reveal-or-hide toggle button without enabling the auto loop. The README closes with notes on performance and scale invariance. Cell size, vignette range, and edge fade are computed in CSS pixels using the device pixel ratio, so a pixels-organic cell looks the same physical size on small and large cards. All instances share a single Three.js WebGL renderer and one WebGL context, frames are capped at 30 fps via a requestAnimationFrame accumulator, off-screen cards are paused by an IntersectionObserver, and image bitmaps are cached by URL across instances. The licence is MIT.

Copy-paste prompts

Prompt 1
Show me a minimal Next.js page that uses ImageGeneration with the pixels-organic preset
Prompt 2
Wire img-fx to a ref so a button calls triggerReveal and triggerHide on click
Prompt 3
Tune revealDelayRange and revealHoldMs to make the reveal cycle pause for 3 seconds
Prompt 4
Add a custom cardBg color to img-fx and explain how that affects the shader proximity logic
Prompt 5
Subscribe to onCycle from img-fx and log each phase change to the console
Open on GitHub → Explain another repo

Generated 2026-05-22 · Model: sonnet-4-6 · Verify against the repo before relying on details.