summaryrefslogtreecommitdiff
path: root/tools/render_web.mjs
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-30 21:34:41 -0300
committerGabriel Schneider <[email protected]>2026-11-12 13:22:02 -0300
commit2348776791e9dd17afeb12a06ba42a4a71917bcf (patch)
tree780c4b12b76c8b97a28408dd40944d65f159fdc7 /tools/render_web.mjs
parent590ba7b9b579b97e34b51ab7e3460ebc85713343 (diff)
downloadsketchbook-2348776791e9dd17afeb12a06ba42a4a71917bcf.tar.gz
sketchbook-2348776791e9dd17afeb12a06ba42a4a71917bcf.zip
sketchbook: a drawing layer on top, host fixes for replay and migration
Diffstat (limited to 'tools/render_web.mjs')
-rw-r--r--tools/render_web.mjs13
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/render_web.mjs b/tools/render_web.mjs
new file mode 100644
index 0000000..1327310
--- /dev/null
+++ b/tools/render_web.mjs
@@ -0,0 +1,13 @@
+// Draws test/render.zig (targets, blend modes, image placement and tint,
+// colours per subpath, antialiased edges) in headless Chrome and compares
+// it with the native host's screenshot of the same frame.
+// usage: node tools/render_web.mjs <web dir> <native.png> [chrome]
+import {withPage, compareScript, report} from './chrome.mjs';
+
+const [dir, nativePng, chromePath] = process.argv.slice(2);
+const points = {target: [30, 70], tinted: [140, 70], targetBlue: [20, 80], turned: [300, 60], add: [80, 175], addRect: [160, 150],
+ addImage: [156, 196], colors: [230, 160], ring: [350, 137], soft: [236, 236], softTint: [286, 236], line: [100, 280]};
+await withPage({dir, extra: {'/native.png': nativePng}, width: 400, height: 300, chromePath}, async evaluate => {
+ const tolerance = 3;
+ report(await evaluate(`(async () => { sketch.frame(performance.now()); sketch.frame(performance.now() + 16); return await ${compareScript(400, 300, tolerance, points)}; })()`), tolerance);
+});