Published
Edited
Feb 11, 2020
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
const {img1, img2, w, h, data1, data2, diff, ctx: diffCtx} = input;
const r = width / (w * 2);
const ctx = DOM.context2d(width, h * r, 2);

const options = {threshold, includeAA, alpha: 0, aaColor: [255, 240, 0], diffMask:true};
mutable numDifferentPixels = pixelmatch(data1, data2, diff.data, w, h, options);
diffCtx.putImageData(diff, 0, 0);

ctx.drawImage(img1, 0, 0, w * r, h * r);
ctx.drawImage(diffCtx.canvas, w * r, 0, w * r, h * r);
ctx.drawImage(toggle ? img1 : img2, 0, 0, w * r, h * r);
console.log(diff.data);
return ctx.canvas;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import{tracking} from 'https://tbquotelijst.s3-eu-west-1.amazonaws.com/specials/findit/tracking.js'
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more