Carepa
A surface (decision 0016: a drawn backdrop, a pure model, a renderer and a still like a scene, but with no slotted reading zone of its own): a Goan window glazed with oyster shell, filling its host edge to edge (cover-fit): the warm and playful backdrop for Dialog and Drawer.
warm playful
npx @susegad/cli add surface-carepa
The prompt
the prompt
After: the carepa windows of old Goan houses, glazed with the flat, milky shells of the windowpane oyster. Took: a surface that lets light and life through while keeping people's privacy. Left: the shells themselves; the window is drawn, not photographed. (Rules from the harvest request: principle, not likeness.)
The prompt
Draw an old Goan window from the inside, in plain JavaScript on a canvas: a lime-washed wall, a deep reveal, and a teak frame with an arched fan light, divided into a grid of small panes of translucent oyster shell. Render the world outside (sky, a palm, a neighbour's wall, and now and then someone cycling past with a basket of bread) into a tiny offscreen canvas and scale it up, so that through the panes it reads only as soft moving colour. Over each pane lay a milky layer with faint concentric growth lines, and a thin iridescent sheen whose hue shifts with the angle between the pane and the light, so neighbouring panes catch slightly different colours. Let the pointer be the sun: moving it moves the brightest glow and turns the sheen. Fill the whole host element edge to edge (cover-fit, like CSS background-size: cover), so the window works as a dialog's or a drawer's backdrop at any aspect ratio, and so that whatever sits behind it is never legible as text through it. Give it a finished reduced-motion still, and a plain translucent CSS fallback for no JavaScript and no canvas.
The map
| Words in the prompt | Technique | How the code does it |
|---|---|---|
| "Render the world outside… into a tiny offscreen canvas and scale it up" | texture | outside() in render.js paints the street at a tenth of its size into tiny; glass() draws it back at W×H with smoothing on, a blur that costs almost nothing so the passer-by can move every frame. |
| "a milky layer with faint concentric growth lines" | texture | shells() in render.js: each pane, painted once and cached, gets a milky wash (model.js's p.tone varies its alpha slightly) then rings around one corner, like the growth rings of a real valve. |
| "an iridescent sheen whose hue shifts with the angle" | colour | sheenHue(pane, sun) in model.js: pure, reads the angle from the pane to the light around a circle of pinks, greens and blues. sheenNear gives the brightness that falls off with distance. Both are tested in Node (carepa.test.js). |
| "Let the pointer be the sun" | interaction | render.js's mount() tracks the pointer over the host and feeds it into model() as params.sun; without a pointer, driftSun(time) (also pure) moves it slowly across the top of the window. |
| "Fill the whole host element edge to edge (cover-fit)" | layout | mount() measures the host with a ResizeObserver, then scales the fixed 1200×820 composition by max(hostW/W, hostH/H) and centres it, so it covers any box without letterboxing. This is what makes carepa work as a full-bleed dialog backdrop. |
| "never legible as text through it" | honesty | The room (room()) is painted opaque first, a lime-washed wall and a laterite reveal cover the whole canvas; only the small window shows the blurred, shell-milky "outside", which is drawn theatre, not a capture of the real page. There is nothing translucent onto the real DOM behind the surface: it is fully repainted. |
| "a finished reduced-motion still" | honesty | mount({ reducedMotion: true }) calls still() once at a fixed time (4.2s, matching the plate's own still time) with the pointer treated as outside, and never starts the loop. |
| "a plain translucent CSS fallback" | fallback | carepa.css's .sg-carepa-css: background: var(--sg-scrim) with a light blur, using tokens only, no canvas and no JavaScript. :has(canvas) steps the CSS wash aside once the drawing has mounted, so a page with JavaScript sees the drawing, not both. |
A surface is a scene-like backdrop: a pure model, a renderer and a still, but
no slotted reading zone of its own (compare docs/CHARTER.md's scene
contract). Carepa is the warm and playful register's backdrop for Dialog and
Drawer, and any other place that needs "content present but not legible":
the page behind stays present but is never readable as text through it.
After, what we took, what we left
After the carepa windows of old Goan houses: rooms glazed not with clear glass but with small, flat panes cut from the windowpane oyster, so what is outside comes in only as soft colour and moving light, never as detail.
What we took: the same job, done for a screen. A backdrop that keeps the page behind it present, but never lets it be read as text, pane by pane, the way the shells never let the lane outside be read as a lane.
What we left: the shells themselves, and the room they came from. This
surface is drawn, not photographed, and it draws a window, not that one.
Ported by copying from the sketchbook's Carepa plate
(C:\Projects\asymmetrica-web\explorations\susegad\pieces\carepa.js, read
only, commit 06ec47e on explore/susegad), per
the Volume III harvest. The plate's second round
fixed a fault it called "too see-through"; this port keeps that fix by
painting the room opaque first (room() in render.js), so nothing of the
real page ever shows through the surface, only the drawn, blurred world
outside the window does, and only as colour.
Usage
import { mount } from './surfaces/carepa/index.js';
const host = document.querySelector('.scrim'); // sized by CSS to fill its container
const carepa = mount(host, { seed: 1, register: 'warm', reducedMotion: false });
// later
carepa.setRegister('playful'); // brighter, more of the shells catch light
carepa.reseed(2);
carepa.still(); // the finished reduced-motion frame
carepa.destroy();
host should have .sg-carepa-css (from carepa.css) for the no-JavaScript
and no-canvas fallback: a plain, dimmed, tokens-only wash. mount() appends
a canvas[aria-hidden="true"] inside host and the CSS steps its own
background aside once the canvas is there (:has(canvas)), so nothing is
painted twice.
Registers
- Quiet never mounts carepa (per Wave 5's brief): Dialog and Drawer use a plain dimmed CSS backdrop instead. Carepa is warm and playful only.
- Warm: the shells catch pink, green and blue at their own angle from the
pointer (or from
driftSun(time)when nothing points at it). - Playful:
register: 'playful'raisesmodel()'sbrightento 1.35, so every shell catches more light, not only the ones nearest the pointer ("the same, brighter and more of them").
Accessibility and honesty
The surface is aria-hidden: it carries no meaning of its own, only
theatre (A2). The dialog or drawer's own content is what a screen reader
and a no-JavaScript visitor see; carepa never stands in for that content.
Reduced motion shows one finished still, drawn once, with the pointer
treated as outside the window so the light sits where driftSun(4.2)
(the plate's own still time) leaves it. The surface pauses whenever its
host is not driving it (there is no independent play()/pause() for a
surface off screen the way a <sg-scene> has one; Dialog and Drawer call
mount() only while open, and destroy() on close, so nothing runs behind
a closed dialog).
Performance
Cover-fit scaling means the composition is always drawn at its own 1200×820
logical resolution and stretched by the canvas's own transform, exactly like
stage()'s device-pixel handling elsewhere in the library, so a very wide or
very tall host never costs more geometry, only a different scale factor.
Painted-once layers (room(), shells()) are cached per seed on plain
offscreen canvases and blitted with one drawImage a frame (A4); only the
pointer-driven sheen gradients and the small "outside" canvas (a tenth
size) redraw live.