summaryrefslogtreecommitdiff
path: root/tools/render_web.mjs
blob: 1327310d9f64f96ec984c6e810dd1d2426eb83ef (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
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);
});