hold S and scrub to strip active color from the canvas
Hunter
Sunday, November 22nd, 2026 at 3:12 PM
25 - hold any of the , , and/or  keys and move your cursor up/down to change the , , and/or  of the active color
26 - hold any combination of the above to change size, shape, and/or color simultaneously
27 - hold `C` and click anywhere to pick up the color underneath your brush
28 +- hold `S` and scrub to strip the active color from the canvas
29 - pinch with two fingers to zoom in / out (or use `⌘ +` / `⌘ -`)
30 - drag with two fingers to pan around the canvas
31
Binary files differ.
133 colorAnimFromR = r; colorAnimFromG = g; colorAnimFromB = b;
134 colorAnimToR = r; colorAnimToG = g; colorAnimToB = b;
135 }
136 +
137 +// holding S strips the active color instead of painting it. black is what stripping leaves behind, so stripping black does nothing
138 +function stripping() {
139 + return !!keys['s'] && (r !== 0 || g !== 0 || b !== 0);
140 +}
203 }
204
205 function localPaintLine(x0, y0, x1, y1) {
206 + // stripping black would turn black into black; not worth an undo step
207 + if (keys['s'] && !stripping()) return;
208 + const x = stripping() ? 1 : 0;
209 const fresh = strokeFor(chunks.id);
210 if (net.on) {
- fillRaster(overlayFor(chunks.id), rasterize([x0, y0, x1, y1], brush, roundness), [r, g, b]);
- net.paint(x0, y0, x1, y1);
211 + const ras = rasterize([x0, y0, x1, y1], brush, roundness);
212 + if (x) stripOverlay(chunks.id, ras, [r, g, b]);
213 + else fillRaster(overlayFor(chunks.id), ras, [r, g, b]);
214 + net.paint(x0, y0, x1, y1, x);
215 return;
216 }
217 const a = 'a' + stroke.a;
- applyPaint(chunks, { a, o: [x0, y0, x1, y1], c: [r, g, b], b: brush, s: roundness }, fresh);
218 + applyPaint(chunks, { a, o: [x0, y0, x1, y1], c: [r, g, b], b: brush, s: roundness, x }, fresh);
219 if (fresh) localAction(a);
220 }
221
224 function paintOpInto(f, op) {
225 if (!op.o || !op.c) return;
226 if (!op.raster) op.raster = rasterize(op.o, op.b, op.s);
- fillRaster(f, op.raster, op.c);
227 + if (op.x) stripRaster(f, op.raster, op.c);
228 + else fillRaster(f, op.raster, op.c);
229 }
230
231 function mergeSpans(row) {
332 if (ctx) ctx.fillRect(sp[i + 1], sp[i + 2], sp[i + 3], sp[i + 4]);
333 }
334 }
335 +
336 +// a raster's spans grouped by tile, each with the box they cover, so a strip reads and writes every touched tile exactly once
337 +function spansByTile(ras) {
338 + const groups = new Map();
339 + const sp = ras.spans;
340 + for (let i = 0; i < sp.length; i += 5) {
341 + const ti = sp[i];
342 + let g = groups.get(ti);
343 + if (!g) {
344 + g = { cx: ras.tiles[ti * 2], cy: ras.tiles[ti * 2 + 1], x0: CHUNK, y0: CHUNK, x1: 0, y1: 0, spans: [] };
345 + groups.set(ti, g);
346 + }
347 + const lx = sp[i + 1], ly = sp[i + 2], w = sp[i + 3], h = sp[i + 4];
348 + if (lx < g.x0) g.x0 = lx;
349 + if (ly < g.y0) g.y0 = ly;
350 + if (lx + w > g.x1) g.x1 = lx + w;
351 + if (ly + h > g.y1) g.y1 = ly + h;
352 + g.spans.push(lx, ly, w, h);
353 + }
354 + return groups.values();
355 +}
356 +
357 +// turn every pixel of color c under the raster black.
358 +// a tile that doesn't exist is already black, so it's left alone rather than created
359 +function stripRaster(map, ras, c) {
360 + dirty = true;
361 + for (const g of spansByTile(ras)) {
362 + const k = chunkKey(g.cx, g.cy);
363 + if (paintClip && !paintClip.has(k)) continue;
364 + const tile = map.get(k);
365 + if (!tile) continue;
366 + const bw = g.x1 - g.x0, bh = g.y1 - g.y0;
367 + const img = tile.ctx.getImageData(g.x0, g.y0, bw, bh);
368 + const d = img.data;
369 + let hit = false;
370 + for (let j = 0; j < g.spans.length; j += 4) {
371 + const sx = g.spans[j] - g.x0, sy = g.spans[j + 1] - g.y0;
372 + for (let y = sy; y < sy + g.spans[j + 3]; y++) {
373 + for (let i = (y * bw + sx) * 4, e = i + g.spans[j + 2] * 4; i < e; i += 4) {
374 + if (d[i] === c[0] && d[i + 1] === c[1] && d[i + 2] === c[2]) {
375 + d[i] = 0; d[i + 1] = 0; d[i + 2] = 0; d[i + 3] = 255;
376 + hit = true;
377 + }
378 + }
379 + }
380 + }
381 + if (hit) tile.ctx.putImageData(img, g.x0, g.y0);
382 + }
383 +}
384 +
385 +// an unacked strip previews on the overlay. it has to match what's on screen and cover each match with opaque black until the echo strips the frame itself
386 +function stripOverlay(fid, ras, c) {
387 + dirty = true;
388 + const frame = frames.find((f) => f.id === fid);
389 + const ov = overlayFor(fid);
390 + for (const g of spansByTile(ras)) {
391 + const k = chunkKey(g.cx, g.cy);
392 + const ft = frame && frame.get(k);
393 + const ot = ov.get(k);
394 + if (!ft && !ot) continue;
395 + const bw = g.x1 - g.x0, bh = g.y1 - g.y0;
396 + const fd = ft ? ft.ctx.getImageData(g.x0, g.y0, bw, bh).data : null;
397 + const img = ot ? ot.ctx.getImageData(g.x0, g.y0, bw, bh) : new ImageData(bw, bh);
398 + const d = img.data;
399 + let hit = false;
400 + for (let j = 0; j < g.spans.length; j += 4) {
401 + const sx = g.spans[j] - g.x0, sy = g.spans[j + 1] - g.y0;
402 + for (let y = sy; y < sy + g.spans[j + 3]; y++) {
403 + for (let i = (y * bw + sx) * 4, e = i + g.spans[j + 2] * 4; i < e; i += 4) {
404 + const src = d[i + 3] === 255 ? d : fd;
405 + if (src && src[i] === c[0] && src[i + 1] === c[1] && src[i + 2] === c[2]) {
406 + d[i] = 0; d[i + 1] = 0; d[i + 2] = 0; d[i + 3] = 255;
407 + hit = true;
408 + }
409 + }
410 + }
411 + }
412 + if (hit) (ot || getOrCreateChunk(g.cx, g.cy, ov)).ctx.putImageData(img, g.x0, g.y0);
413 + }
414 +}
121 const keys = opKeys(op);
122 registerKeys(f, keys);
123 const raster = rasterize(op.o, op.b, op.s);
124 + const x = op.x ? 1 : 0;
125 const last = f.log[f.log.length - 1];
- if (last && last.a === op.a && !last.src && last.on && last.b === op.b && last.s === op.s
126 + if (last && last.a === op.a && !last.src && last.on && last.b === op.b && last.s === op.s && last.x === x
127 && last.c[0] === op.c[0] && last.c[1] === op.c[1] && last.c[2] === op.c[2]) {
128 last.o.push(...op.o);
129 for (const k of keys) last.keys.add(k);
130 last.raster = null;
131 } else {
- f.log.push({ a: op.a, o: op.o.slice(), c: op.c, b: op.b, s: op.s, on: true, keys, raster });
132 + f.log.push({ a: op.a, o: op.o.slice(), c: op.c, b: op.b, s: op.s, x, on: true, keys, raster });
133 }
- fillRaster(f, raster, op.c);
134 + if (x) stripRaster(f, raster, op.c);
135 + else fillRaster(f, raster, op.c);
136 bump(f, keys);
137 if (f === chunks) requestDraw();
138 }
437 const wasDown = keys[k];
438 keys[k] = true;
439 if (!e.metaKey && !e.ctrlKey) {
- if (k === 'z' || k === 'x' || k === 'c' || k === 'r' || k === 'g' || k === 'b') e.preventDefault();
440 + if (k === 'z' || k === 'x' || k === 'c' || k === 'r' || k === 'g' || k === 'b' || k === 's') e.preventDefault();
441 if (k === 'x') startDragMode('roundness');
442 else if (k === 'z') startDragMode('brush');
443 else if (!wasDown && (k === 'r' || k === 'g' || k === 'b')) startDragMode('color');
26 // a fast pen reports far more moves than anyone can see, so segments pile up
27 // into one message per animation frame. a new stroke, frame, color, or brush
28 // starts a new batch, since a batch carries a single style
-net.paint = function (x0, y0, x1, y1) {
29 +net.paint = function (x0, y0, x1, y1, x) {
30 if (!net.on) return;
31 + x = x ? 1 : 0;
32 const cur = net.batch;
- if (cur && cur.a === stroke.a && cur.f === chunks.id && cur.b === brush && cur.s === roundness
33 + if (cur && cur.a === stroke.a && cur.f === chunks.id && cur.b === brush && cur.s === roundness && cur.x === x
34 && cur.c[0] === r && cur.c[1] === g && cur.c[2] === b) {
35 cur.o.push(x0, y0, x1, y1);
36 return;
37 }
38 net.flush();
- net.batch = { t: 'p', k: ++net.key, a: stroke.a, f: chunks.id, o: [x0, y0, x1, y1], c: [r, g, b], b: brush, s: roundness };
39 + net.batch = { t: 'p', k: ++net.key, a: stroke.a, f: chunks.id, o: [x0, y0, x1, y1], c: [r, g, b], b: brush, s: roundness, x };
40 // tracked from the first segment, so the overlay it painted onto is held
41 // until the echo commits it to the frame proper
42 net.pending.push({ k: net.batch.k, f: chunks.id });
121 }
122 f.log = (e.log || []).map((op) => op.src
123 ? { a: op.a, src: op.src, on: op.on }
- : { a: op.a, o: op.o, c: op.c, b: op.b, s: op.s, on: op.on, keys: opKeys(op) });
124 + : { a: op.a, o: op.o, c: op.c, b: op.b, s: op.s, x: op.x ? 1 : 0, on: op.on, keys: opKeys(op) });
125 f.limboBy = e.limboBy || null;
126 return f;
127 }
193 // overlay; this echo is what commits it, so every painter's frame is
194 // the same ops in the same order
195 const f = frames.find((fr) => fr.id === msg.f);
- if (f) applyPaint(f, { a: msg.a, o: msg.o, c: msg.c, b: msg.b, s: msg.s }, !!msg.n);
196 + if (f) applyPaint(f, { a: msg.a, o: msg.o, c: msg.c, b: msg.b, s: msg.s, x: msg.x }, !!msg.n);
197 if (msg.by === net.id) {
198 const i = net.pending.findIndex((p) => p.k === msg.k);
199 if (i < 0) return;
305 for k in range(h):
306 if lo[k] < hi[k]:
307 add_span(spans, y0 + k, lo[k], hi[k])
308 + if op.get('x'):
309 + strip_spans(base, spans, tiles, bytes(op['c']))
310 + return
311 for k in tiles:
312 base[k]
313 line = bytes(op['c']) * CHUNK
314 for y, row in spans.items():
- if len(row) > 1:
- row.sort()
- merged = [row[0]]
- for s, e in row[1:]:
- if s > merged[-1][1]:
- merged.append([s, e])
- elif e > merged[-1][1]:
- merged[-1][1] = e
- row = merged
315 cy = y // CHUNK
316 at = (y - cy * CHUNK) * CHUNK
- for s, e in row:
317 + for s, e in merged_row(row):
318 x = s
319 while x < e:
320 cx = x // CHUNK
324 x = stop
325
326
327 +def merged_row(row):
328 + """a row's spans sorted, with overlapping ones joined"""
329 + if len(row) < 2:
330 + return row
331 + row.sort()
332 + out = [row[0]]
333 + for s, e in row[1:]:
334 + if s > out[-1][1]:
335 + out.append([s, e])
336 + elif e > out[-1][1]:
337 + out[-1][1] = e
338 + return out
339 +
340 +
341 +def strip_spans(base, spans, tiles, target):
342 + """turn every pixel of color target under spans black. base is a Draft:
343 + a tile only in base.under still exists, and one in neither is already
344 + black, so it's left alone rather than created"""
345 + under = getattr(base, 'under', {})
346 + live = {k for k in tiles if k in base or under.get(k) is not None}
347 + if not live:
348 + return
349 + black = b'\x00\x00\x00'
350 + for y, row in spans.items():
351 + cy = y // CHUNK
352 + at = (y - cy * CHUNK) * CHUNK
353 + for s, e in merged_row(row):
354 + x = s
355 + while x < e:
356 + cx = x // CHUNK
357 + stop = min(e, (cx + 1) * CHUNK)
358 + if (cx, cy) in live:
359 + buf = base[(cx, cy)]
360 + p = (at + x - cx * CHUNK) * 3
361 + q = p + (stop - x) * 3
362 + # find can land mid-pixel, so only matches on a pixel boundary count
363 + i = buf.find(target, p, q)
364 + while i >= 0:
365 + if (i - p) % 3 == 0:
366 + buf[i:i + 3] = black
367 + i = buf.find(target, i + 3, q)
368 + else:
369 + i = buf.find(target, i + 1, q)
370 + x = stop
371 +
372 +
373 def composite(dst, src):
374 for (cx, cy), sbuf in src.items():
375 dbuf = dst[(cx, cy)]
468 log = f['log']
469 last = log[-1] if log else None
470 if (last and last['a'] == op['a'] and 'src' not in last and last['on']
- and last['c'] == op['c'] and last['b'] == op['b'] and last['s'] == op['s']):
471 + and last['c'] == op['c'] and last['b'] == op['b'] and last['s'] == op['s']
472 + and last.get('x', 0) == op.get('x', 0)):
473 last['o'].extend(op['o'])
474 return
475 log.append(op)
648 's': float(msg.get('s')),
649 'on': True,
650 }
651 + # x marks a strip: the op turns its color black instead of painting it
652 + if msg.get('x'):
653 + op['x'] = 1
654 with self.lock:
655 f = self.listed(msg.get('f'))
656 if f is None:
660 done = self.new_action(conn, op['a'], {'kind': 'stroke', 'f': f['id']}) if new else []
661 self.append(f, op)
662 out = {'t': 'p', 'f': f['id'], 'a': op['a'], 'o': op['o'], 'c': op['c'], 'b': op['b'], 's': op['s'], 'by': conn.id}
663 + if op.get('x'):
664 + out['x'] = 1
665 if new:
666 out['n'] = 1
667 # the painter's own tag for this batch, so they can recognise it