labs

riso tide

2026-09-23
3.5 px
1.5 px
4

four plates, one picture

a riso print is not a filter over a picture, it is four pictures. each ink is its own plate, drawn as nothing but coverage, then screened into dots at its own angle and laid on the paper one pull at a time, and the colours you see are only where the plates overlap.

the little printing press

so the scene is drawn four times per frame into alpha, and a small press in plain javascript does the rest: a baked threshold map per ink, fixed to the sheet so the tide slides under the dots instead of dragging them along, blotchy starvation where the drum ran short, and a slip per plate for the registration that never quite lines up.

there is no black ink anywhere; the rocks are pink, green and blue stacked.

twelve drawings a second

it runs on twos, twelve drawings a second, which is how printed animation moves and also how a per-pixel press stays inside a frame. the idea came from sevenevesai's riso-windowseat, which makes whole films this way.

take it with you

three steps, and the stage above runs in your own project.

  1. install

    nothing to add. it runs on react alone, 18 or newer.

  2. copy

    7 files, kept together in one folder, riso/. the styles travel with them.

    "use client";
    
    import { useEffect, useRef } from "react";
    import { useReducedMotion } from "./motion";
    import { createPrinter, type Frame } from "./printer";
    import { LOOP } from "./tide";
    import "./riso.css";
    
    interface Props {
      // px between halftone dots: lower is finer
      pitch?: number;
      // px each plate drifts off register
      slip?: number;
      // how many of the four inks print, from yellow up
      plates?: number;
      // false prints flat ink with no dots
      screened?: boolean;
      label?: string;
    }
    
    const FPS = 12;
    
    const STILL = 1.7;
    
    type Send = (f: Frame) => void;
    
    // Inspired by github.com/sevenevesai/riso-windowseat.
    export default function RisoPrint({
      pitch = 3.5,
      slip = 1.5,
      plates = 4,
      screened = true,
      label = "A risograph print of a rock pool from above: the tide goes out, a crab comes out from under a rock to the pool's edge, and runs home as the sea comes back in.",
    }: Props) {
      const params = { pitch, slip, plates, screened };
      const reduced = useReducedMotion();
      const box = useRef<HTMLDivElement>(null);
      const send = useRef<Send | null>(null);
      const time = useRef(0);
      const latest = useRef(params);
      latest.current = params;
    
      const request = useRef(() => {});
      request.current = () => {
        const holder = box.current;
        const canvas = holder?.querySelector("canvas");
        if (!holder || !canvas || !send.current) return;
        const rect = holder.getBoundingClientRect();
        if (rect.width < 2 || rect.height < 2) return;
        const dpr = window.devicePixelRatio || 1;
        const width = Math.round(rect.width * dpr);
        const height = Math.round(rect.height * dpr);
        canvas.style.width = `${width / dpr}px`;
        canvas.style.height = `${height / dpr}px`;
        const frame = Math.floor(time.current * FPS);
        holder.dataset.frame = String(frame);
        send.current({ ...latest.current, t: frame / FPS, width, height, dpr });
      };
    
      useEffect(() => {
        const holder = box.current;
        if (!holder) return;
        const canvas = document.createElement("canvas");
        canvas.setAttribute("role", "img");
        canvas.setAttribute("aria-label", label);
        holder.append(canvas);
    
        let worker: Worker | null = null;
        if ("transferControlToOffscreen" in canvas && typeof OffscreenCanvas !== "undefined") {
          worker = new Worker(new URL("./press.worker.ts", import.meta.url), { type: "module" });
          const offscreen = canvas.transferControlToOffscreen();
          worker.postMessage({ canvas: offscreen }, [offscreen]);
          let busy = false;
          let waiting: Frame | null = null;
          worker.onmessage = (event: MessageEvent<number>) => {
            holder.dataset.cost = String(Math.round(event.data));
            holder.dataset.inked = "";
            busy = false;
            if (waiting) {
              const next = waiting;
              waiting = null;
              busy = true;
              worker!.postMessage(next);
            }
          };
          send.current = (f) => {
            if (busy) waiting = f;
            else {
              busy = true;
              worker!.postMessage(f);
            }
          };
        } else {
          const print = createPrinter(canvas, (w, h) => {
            const layer = document.createElement("canvas");
            layer.width = w;
            layer.height = h;
            return layer.getContext("2d", { willReadFrequently: true })!;
          });
          send.current = (f) => {
            print(f);
            holder.dataset.inked = "";
          };
        }
        request.current();
    
        const observer = new ResizeObserver(() => request.current());
        observer.observe(holder);
        return () => {
          observer.disconnect();
          worker?.terminate();
          send.current = null;
          canvas.remove();
        };
      }, [label]);
    
      useEffect(() => {
        request.current();
      }, [pitch, slip, plates, screened]);
    
      useEffect(() => {
        if (reduced) {
          time.current = STILL;
          request.current();
          return;
        }
    
        let raf = 0;
        let last = 0;
        let printed = -1;
        let onScreen = false;
    
        const tick = (now: number) => {
          if (last) time.current = (time.current + Math.min(0.1, (now - last) / 1000)) % LOOP;
          last = now;
          const frame = Math.floor(time.current * FPS);
          if (frame !== printed) {
            printed = frame;
            request.current();
          }
          raf = requestAnimationFrame(tick);
        };
        const start = () => {
          if (raf) return;
          last = 0;
          raf = requestAnimationFrame(tick);
        };
        const stop = () => {
          cancelAnimationFrame(raf);
          raf = 0;
        };
        const sync = () => {
          if (onScreen && document.visibilityState === "visible") start();
          else stop();
        };
    
        const io = new IntersectionObserver(([entry]) => {
          onScreen = entry?.isIntersecting ?? false;
          sync();
        });
        if (box.current) io.observe(box.current);
        document.addEventListener("visibilitychange", sync);
    
        return () => {
          stop();
          io.disconnect();
          document.removeEventListener("visibilitychange", sync);
        };
      }, [reduced]);
    
      return <div className="riso-lab" ref={box} />;
    }
    
  3. use

    the stage above, exactly as it runs here. the comments mark what to change.

    example.tsx
    "use client";
    
    import RisoPrint from "./riso/RisoPrint";
    
    export default function RisoExample({
      pitch = 3.5,
      slip = 1.5,
      plates = 4,
      screened = true,
    }: {
      // the four controls above the stage
      pitch?: number;
      slip?: number;
      plates?: number;
      screened?: boolean;
    }) {
      // the scene is drawn in tide.ts; the press in print.ts turns any drawing into plates
      return <RisoPrint pitch={pitch} slip={slip} plates={plates} screened={screened} />;
    }