summaryrefslogtreecommitdiff
path: root/tools/render_web.mjs
diff options
context:
space:
mode:
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);
+});