
2026-11-18
I wanted a calm place to focus at work: a timer, a to-do list, some rain sounds, and nothing else competing for attention. Apps like Flocus get the mood right, so I started building my own version. Somewhere along the way it grew a second half: a tiny pixel-art room that you furnish with the minutes you spend focusing.
The result is Nook: a pomodoro dashboard on one side, and a little isometric room that grows with you on the other.
Try it live at nook-pomodoro.web.app.
The room in Nook: everything here was bought with focus minutes
The first half is a classic focus dashboard: a pomodoro timer, tasks, notes, an ambience mixer, a music player for YouTube or Spotify links, and animated backgrounds. Every widget is a draggable glass card, so you can arrange the screen however you like. A small robot buddy watches your cursor, cheers when you finish a task, and notices when you wander off to another tab in the middle of a session.
The dashboard view
Two parts of it turned out to be more interesting than expected.
The obvious approach, setInterval that subtracts one second each tick, breaks as soon as the tab goes into the background. Browsers throttle timers in inactive tabs, so a 25-minute session can quietly take 27. The fix is to count down against a deadline instead of counting ticks:
const start = () => { endAt.current = Date.now() + remaining * 1000 setRunning(true) } useEffect(() => { if (!running) return const id = setInterval(() => { setRemaining(Math.max(0, Math.round((endAt.current - Date.now()) / 1000))) }, 250) return () => clearInterval(id) }, [running])
A tick can be late, but it can never be wrong: whenever it fires, it reads the true time left.
I didn't want to ship megabytes of rain recordings, so every ambience sound is synthesized live with the Web Audio API. Everything starts from noise. White noise has equal energy at all frequencies and sounds harsh. Pink noise falls off at higher frequencies and sounds like steady rain. Brown noise falls off even more steeply and sounds like a deep rumble.
Brown noise is just a leaky random walk:
let last = 0 for (let i = 0; i < length; i++) { const white = Math.random() * 2 - 1 last = (last + 0.02 * white) / 1.02 data[i] = last * 3.5 }
To loop a noise buffer forever without an audible click at the seam, I generate a little extra and cross-fade the tail into the head, so the last sample flows straight into the first:
for (let i = 0; i < length; i++) { if (i < fade) { const t = i / fade out[i] = raw[i] * t + raw[length + i] * (1 - t) } else out[i] = raw[i] }
From there, each sound is a small audio graph:
The second half started from a reference image of an isometric pixel-art shop, the kind of cozy diorama you see on r/PixelArt. I wanted something like that, but I also wanted it to change: new furniture, day and night, a character who reacts to the timer. Drawing every combination by hand wasn't realistic, so the whole room is drawn procedurally.
Isometric pixel art uses a 2:1 grid: moving one unit along an axis moves two pixels sideways and one pixel down. With world coordinates x, y (floor) and z (height), the projection is a single line:
const P = (x, y, z = 0) => [ Math.round(OX + x - y), Math.round(OY + (x + y) / 2 - z), ]
Everything is drawn onto a tiny 256×224 canvas, which is then scaled up 3–4× with image-rendering: pixelated so each pixel becomes a crisp square.
My first attempt used the normal canvas path API, ctx.fill(). Scaled up, it looked muddy: canvas anti-aliases polygon edges, so every slanted edge got a fringe of half-transparent pixels, and at 4× those turned into blurry smears.
So the painter fills shapes with its own scanline rasterizer: for every pixel row, find where the polygon's edges cross the row's center line and fill whole pixels between those crossings. Each pixel is either fully colored or not colored at all:
for (let row = minY; row < maxY; row++) { const yc = row + 0.5 const xs = [] for (const [[ax, ay], [bx, by]] of edges) { if ((ay <= yc && by > yc) || (by <= yc && ay > yc)) xs.push(ax + ((yc - ay) / (by - ay)) * (bx - ax)) } xs.sort((a, b) => a - b) for (let i = 0; i + 1 < xs.length; i += 2) ctx.fillRect(Math.round(xs[i]), row, Math.round(xs[i + 1]) - Math.round(xs[i]), 1) }
Almost every object is built from one primitive: a shaded box. A box shows three faces (top, left and right), each a lighter or darker shade of a base color. Then come the two details that make it read as pixel art instead of flat shapes: a dark outline around the silhouette and a bright line along the top front edges, like light catching a bevel.
A desk is four legs, a drawer block and a tabletop. A bookshelf is a box with a dark recess and rows of thin, colored "books" painted onto its front face. Things are drawn back to front, sorted by how close they sit to the viewer, so nearer furniture naturally covers what's behind it.
The room redraws ten times per second, which leaves room for small touches:
lighter blend mode, so lights glow instead of being darkened.
The Night lab theme after dark: lights are added back on top of the dimmed room
The room gives you a reason to come back, so the last piece was a simple economy. The key rule is that rewards only pay out when a focus session completes. Skipping doesn't count, and since coins scale with minutes, a 5-minute session can't out-earn a 25-minute one.
function nextStreak(streak, today) { if (streak.last === today) return { count: streak.count, bonus: 0 } const count = streak.last === yesterday(today) ? streak.count + 1 : 1 return { count, bonus: 5 + 2 * Math.min(count, 10) } }
Best streaks of 3, 7, 14 and 30 days put bronze, silver, gold and diamond trophies on a shelf in the room.
The shop has 24 pieces of furniture, 4 room themes, and a wardrobe for the character: free colors and hair styles, plus accessories (glasses, headphones, cat ears, a wizard hat, a crown at level 8) that show up on the character at the desk.
The wardrobe: customize your character, then watch them wear it at the desk
Since writing this, the room has grown into a small living world, inspired by Habbo Hotel and Stardew Valley:
Next on the list: daily quests and a second room.