Curves draw the rules they land in; tabs for folded and scrolled panes; peek on both axes
- A curve runs on along the rule under its pane's title (any kind of pane: section, page, article, article section) and draws it, the pane's own rule left out, so the two are one stroke, set on device pixels (the curves' layer measured from its whole pixel; a hairline is one device pixel). - The landing: the title's rule when it shows, else the tab's foot, whether the pane is folded down its column or scrolled past its title. A pane scrolled past its title shows its tab at its top (an observer on the rule, nothing per scroll or key). - A curve out of a folded pane whose source is out of sight leaves from the end of its tab's foot, solid, the foot drawn with it; the stacked pane's own top edge under it is left out. - Colours: the panes' and curves' colour came out as the neutral ink on every curve (a selector outweighed the colour's); the neutral is nearer the text's ink. Colour depends on the tree only. - A covered pane peeks out across and down at once, and stays out while the wheel scrolls it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014yB6q4BHMwptTX3YFtkRab
This commit is contained in:
1 parent
66d25eea7f
commit
8f6afaecdd
6 files changed
+643
-94
No files matched your search
@@ -7,6 +7,7 @@
|
||||
* Wikipedia's fixtures in server/wikiMock.ts).
|
||||
*/
|
||||
import { writeFileSync } from "node:fs";
|
||||
import { inflateSync } from "node:zlib";
|
||||
import type { APIRequestContext, Page } from "@playwright/test";
|
||||
|
||||
/** A keypress → paint timing, as the page records it. */
|
||||
@@ -119,3 +120,40 @@ export async function seedLinks(request: APIRequestContext) {
|
||||
const res = await request.post("/api/ops", { data: { author: "linker", message: "Seed links for the link tests", ops } });
|
||||
if (!res.ok()) throw new Error(`seeding links failed: ${res.status()} ${await res.text()}`);
|
||||
}
|
||||
|
||||
/** A screenshot's pixels (a PNG of 8-bit RGB or RGBA, as Playwright writes them): px(x, y) is [r, g, b]. */
|
||||
export function pixels(buf: Buffer): { w: number; h: number; px: (x: number, y: number) => [number, number, number] } {
|
||||
let at = 8;
|
||||
let w = 0;
|
||||
let h = 0;
|
||||
let type = 6;
|
||||
const data: Buffer[] = [];
|
||||
while (at < buf.length) {
|
||||
const len = buf.readUInt32BE(at);
|
||||
const kind = buf.toString("ascii", at + 4, at + 8);
|
||||
const body = buf.subarray(at + 8, at + 8 + len);
|
||||
if (kind === "IHDR") {
|
||||
w = body.readUInt32BE(0);
|
||||
h = body.readUInt32BE(4);
|
||||
type = body[9];
|
||||
} else if (kind === "IDAT") data.push(body);
|
||||
at += 12 + len;
|
||||
}
|
||||
const bpp = type === 6 ? 4 : 3;
|
||||
const raw = inflateSync(Buffer.concat(data));
|
||||
const stride = w * bpp;
|
||||
const out = Buffer.alloc(h * stride);
|
||||
for (let y = 0; y < h; y++) {
|
||||
const f = raw[y * (stride + 1)];
|
||||
for (let i = 0; i < stride; i++) {
|
||||
const x = raw[y * (stride + 1) + 1 + i];
|
||||
const a = i >= bpp ? out[y * stride + i - bpp] : 0;
|
||||
const b = y ? out[(y - 1) * stride + i] : 0;
|
||||
const c = y && i >= bpp ? out[(y - 1) * stride + i - bpp] : 0;
|
||||
const p = a + b - c;
|
||||
const pr = Math.abs(p - a) <= Math.abs(p - b) && Math.abs(p - a) <= Math.abs(p - c) ? a : Math.abs(p - b) <= Math.abs(p - c) ? b : c;
|
||||
out[y * stride + i] = (x + [0, a, b, (a + b) >> 1, pr][f]) & 255;
|
||||
}
|
||||
}
|
||||
return { w, h, px: (x, y) => [out[y * stride + x * bpp], out[y * stride + x * bpp + 1], out[y * stride + x * bpp + 2]] };
|
||||
}
|
||||
Reference in new issue
Block a user