← Pixel Current on BitBlurPixel Current 0.2.0
Free Canvas2D pixel transitions for text and transparent images. Use the code in personal projects, client work and commercial products under the included MIT licence. Keep its copyright and licence notice with redistributed code. No membership, API key or rendering service is needed.
Start here: read the browser guide or open the examples. The package is a small motion primitive, not a video editor or full animation framework.
Your first transition
Unzip the package into your own project. Serve that folder over HTTP using your existing local development server. If Python is installed, a simple local option is python -m http.server 8080 --bind 127.0.0.1; open http://127.0.0.1:8080/guide.html and stop the server with Ctrl+C when finished. No install step is needed. Browser module imports should not be opened through file://.
<h1>From idea to reality</h1>
<canvas id="pixels" aria-hidden="true"
style="width:100%;height:320px;display:block"></canvas>
<button id="play" type="button" disabled>Play transition</button>
<p id="status" role="status">Loading the example…</p>
<script type="module">
import {createPixelCurrent} from './pixel-current.mjs';
const button = document.querySelector('#play');
const status = document.querySelector('#status');
const app = createPixelCurrent(document.querySelector('#pixels'), {
from: {kind:'text', value:'IDEA'},
to: {kind:'text', value:'REALITY'},
recipe: {count:900, seed:52}
});
try {
await app.ready;
button.disabled = false;
status.textContent = 'Ready';
button.onclick = async () => {
app.setProgress(0);
await app.play({to:1, duration:2400});
};
} catch {
status.textContent = 'Animation unavailable. The page still works.';
}
addEventListener('pagehide', () => app.dispose(), {once:true});
</script>
Keep the real text, navigation and buttons in HTML. The canvas is decorative: it must not be the only way to read content or activate a control. A dedicated canvas needs explicit CSS dimensions. If you retain a disposed view in a client router or back/forward cache, create a new instance when it returns.
Working examples
The four browser examples use only files in this package. The React example needs your own React toolchain; it is not a standalone browser page. Local images are decoded in the browser and are not uploaded. A built-in, code-drawn mark lets you test without supplying an image.
API, recipes and troubleshooting
Run node --test contract.test.mjs to check validation and deterministic geometry. Use integrity.json to verify extracted files; manifest.json records the downloadable archive hash. A passing contract test is not a device-performance guarantee. Physical iPhone/Safari and Firefox qualification are not yet recorded.
Upgrading from 0.1.0
0.1.0 stays intact with its original evaluation terms. 0.2.0 is a separate MIT-licensed release. The particle algorithm and API are retained; package/runtime/type/schema versions now read 0.2.0. If you explicitly store recipe.version, change it to 0.2.0 when adopting this version. A recipe without a version uses the loaded runtime version. Do not mix modules from the two version folders. Previously exported HTML contains its old runtime and notices; re-export using 0.2.0 to obtain this release's code and terms.
Terms
The MIT licence covers the included BitBlur runtime, examples and documentation, including commercial use and modification. It does not grant rights to BitBlur trademarks or someone else's uploaded artwork, fonts, voices or music. Those are not included. Optional React is supplied and licensed by your application. No paid support, service-level agreement or perpetual browser compatibility is promised.
API reference
Import createPixelCurrent from pixel-current.mjs. The core has no runtime dependencies. Type declarations live beside the module.
Constructor
createPixelCurrent(canvas, {from, to, recipe?, motion?, onProgress?})
Use a dedicated HTML canvas with an explicit CSS width and height. The instance owns its drawing context, backing resolution, event listeners and observers. DPR is capped at 1.5. Await app.ready before controlling it. Handle rejection and leave your HTML fallback usable. Do not start a view after its owner has unmounted.
onProgress(number) runs when progress changes. Keep it inexpensive. Do not feed its values straight back into setProgress during playback.
Sources
Text: {kind:'text', value:'IDEA'}. One to 42 visible Unicode code points, trimmed; controls and empty strings reject. System font metrics vary by OS.
Image: {kind:'image', pixels:{width,height,data}}. data is RGBA bytes in a Uint8Array or Uint8ClampedArray; dimensions must be valid and no greater than 4096 per side. Completely transparent input rejects. Transparent marks preserve their visible silhouette; an opaque photograph remains a rectangle.
loadLocalImage(file) from image-input.mjs checks PNG/JPEG/WebP file headers, rejects files over 5 MB or dimensions over 4096 before decoding, and resamples to at most 900 pixels per side. It returns {pixels,dataURL,...}. The caller owns URL/CORS safety for any separately decoded remote image. This adapter does not request remote URLs.
Controls
| Method | Result and responsibility |
ready | Promise of initial source readiness. Catch source errors. |
play({to:1,duration:2400}) | Promise resolving to {status,progress}. Destination is normalized; duration must be 100–30000 ms. to:0 reverses. |
setProgress(0.4) | Seek immediately; finite values clamp to 0–1. Ends current finite playback. |
pause() / resume() | Hold and resume a finite passage. Hidden/offscreen time does not advance it. |
setSources(from,to) | Promise; validates and replaces both masks together. Invalid replacements retain previous masks. Superseded/disposed replacements resolve false. |
configure(recipe) | Promise; validates a closed recipe. Count/seed changes resample. Catch invalid settings. |
setView({yaw,pitch}) | Adjust projection; angles are radians and must be finite. It does not create or reconstruct 3D geometry. |
setMotionAllowed(false) | Application preference; OS reduced motion still takes precedence. Playback settles without ongoing animation. |
bindScroll({target,start:0.82,end:0.18}) | Returns an idempotent detach function. Requires a positive-size element and valid anchors. Detach on owner cleanup. |
inspect() | Version, readiness, disposal, progress, count, playing/paused state, RAF, visibility, CSS dimensions, DPR, frames, last CPU draw time and scroll-binding count. Not a GPU/FPS benchmark. |
dispose() | Idempotent teardown: cancel owned RAFs, observers/listeners/bindings and release particle arrays. Recreate for a new view. |
Playback completion can be finished, reduced-motion, motion-disabled, seek, superseded, sources-changed, scroll or disposed. An interruption is a resolved completion reason, not necessarily an error. Inspect it if your application distinguishes completion from cancellation. Invalid API input can throw/reject.
Scroll ownership
Progress starts at zero when the target's top meets 82% of viewport height and reaches one when its bottom meets 18%. Make the section tall enough; use a sticky canvas if it should remain visible. Use one progress owner: a scroll binding, finite playback, or your application's router/gesture state. An active scroll update supersedes finite playback.
React
PixelCurrentCanvas from react-adapter.mjs creates and disposes a runtime instance. Pass stable or memoized from, to and recipe; changing their identities recreates it. Pass normalized controlled progress, a host motion preference, onError and onProgress if needed. React is an optional peer supplied by your app. The provided JSX example keeps a readable heading and a keyboard-operable progress input. No cloud state or React installation is bundled.
Recipes and accessibility
Start with 900 particles on a phone-size area. Increase only after profiling your actual page and device. Less depth/spread often makes interface transitions more readable than large bursts.
const gentle = {count:900, seed:52, spread:0.2, depth:0.15, bend:0.25, size:2};
const mark = {count:1200, seed:7, preserveColor:true, spread:0.3, bend:0.4};
| Field | Accepted values | Purpose |
version | Optional 0.2.0 | Pin to this runtime; omit to use its default. |
count | Integer 128–5000 | Particle budget. Start low. |
seed | Integer 0–4294967295 | Stable sampling and matching. |
spread, depth, bend | Finite 0–1 | Dispersion, projection depth and trajectory bend. |
size | Finite 0.5–6 | Drawn pixel size. |
color, accent | Six-digit #RRGGBB | Runtime tint colours. |
preserveColor | Boolean | Retain image-source colour. |
Unknown fields, unsupported recipe versions and non-finite values reject. A recipe is data, never executable code. Loading it does not load an image: supply image pixels separately. An exported image recipe may indicate that its source file is still required.
Accessible integration
- Keep every meaningful message, link and control in ordinary HTML. Mark a decorative canvas
aria-hidden="true". If the canvas conveys additional information, describe that information in real text as well.
- Start finite animation from an intentional action when possible. Do not flash, shake or loop a required reading surface.
- The OS reduced-motion preference wins. You can additionally call
setMotionAllowed(false) for an application preference. Leave navigation and content available in either mode.
- Progress controls need visible labels and native keyboard support. Do not announce every animation frame to assistive technology.
- Preserve readable contrast; an attractive particle colour is not a substitute for text contrast.
- With JavaScript disabled or canvas unavailable, the page must still explain its purpose and expose its real actions.
Text sampling uses system fonts, so exact text pixels differ between operating systems. Deterministic geometry assumes identical sampled inputs, recipe and viewport. There is no guarantee that a chosen recipe produces identical screenshots on every device.
Troubleshooting and support limits
| Symptom | Check |
| Module fails to load | Use HTTP, not file://. Keep relative module paths and correct JavaScript MIME types. Keep all runtime files from the same version. |
| Blank canvas | Give it explicit CSS dimensions, await ready, catch errors, check text length or image alpha. Keep readable HTML as fallback. |
| It jumps to the end | OS reduced motion or host motion preference may be off. This is intentional. |
| No movement while hidden | Offscreen/hidden playback pauses intentionally. Return it to view. |
| Photo stays rectangular | Opaque backgrounds are visible geometry. Supply a transparent mark for a silhouette. |
| Image rejects | PNG/JPEG/WebP only; correct header/MIME, at most 5 MB and 4096 pixels per side. SVG and arbitrary URLs are not local-file inputs. |
| Progress fights the scroll | Detach the scroll binding before finite playback, or use only application-controlled progress. |
| React keeps restarting | Memoize the source and recipe objects; dispose or let the adapter clean up at unmount. |
| Saved recipe rejects | Update an explicit 0.1.0 recipe version to 0.2.0 when adopting the new runtime. Do not mix versions. |
| A route returns to a dead view | A disposed instance cannot be reused. Recreate it on mount or restore; the examples reload on back/forward-cache restoration. |
| Page feels heavy | Lower count, avoid many simultaneous canvases, keep callbacks small and profile your device. Do not use CPU draw time as an FPS guarantee. |
What it does not do
No video rendering, arbitrary DOM capture, hidden geometry reconstruction, game physics, image generation, remote rendering, cloud storage or cross-device synchronization. This is a controlled pixel transition primitive.
Verification and support
Contract checks cover validation and deterministic geometry. The previous runtime has separate consumer checks in headless Edge; each release's accompanying qualification notes identify exactly what was tested. Physical iPhone/Safari and other-engine performance still require device testing. Feature detection and readable fallbacks matter.
Report a minimal example, browser/OS, runtime version, dimensions, particle count and the exact error through BitBlur's contact page. Remove personal images and private content first. This free release is provided as-is, without a support response deadline or compatibility guarantee. No analytics or API key is required by this package.