Skip to content

Commit

Permalink
Migrate to skia-canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
s-h-a-d-o-w committed Nov 12, 2024
1 parent c8925fd commit 868b801
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 37 deletions.
6 changes: 3 additions & 3 deletions e2e/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import screenshot from "screenshot-desktop";
import { createCanvas, loadImage } from "canvas";
import { Canvas, loadImage } from "skia-canvas";
import { mkdir, unlink, writeFile } from "node:fs/promises";
import { basename } from "path";
import { main } from "../src/main.js";
Expand All @@ -25,13 +25,13 @@ async function getDiff(

const before = await loadImage(beforeBuffer);
const after = await loadImage(afterBuffer);
const canvas = createCanvas(before.width, before.height);
const canvas = new Canvas(before.width, before.height);
const ctx = canvas.getContext("2d");
ctx.drawImage(before, 0, 0);
ctx.globalCompositeOperation = "difference";
ctx.drawImage(after, 0, 0);

await writeFile(`e2e-output/${name}-diff.png`, canvas.toBuffer());
await writeFile(`e2e-output/${name}-diff.png`, await canvas.toBuffer("png"));

const diffData = ctx.getImageData(0, 0, before.width, before.height).data;
let diff = 0;
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"@types/node": "^22.9.0",
"@types/screenshot-desktop": "^1.12.3",
"@types/yargs": "^17.0.33",
"canvas": "^2.11.2",
"eslint": "^9.13.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
Expand All @@ -41,14 +40,16 @@
"prettier": "^3.3.3",
"rimraf": "^6.0.1",
"screenshot-desktop": "^1.15.0",
"skia-canvas": "^1.0.2",
"tsx": "^4.19.2",
"typescript": "^5.6.3",
"typescript-eslint": "^8.11.0",
"vitest": "^2.1.4"
},
"dependencies": {
"yargs": "17.7.2"
}, "files": [
},
"files": [
"dist/**/*"
]
}
105 changes: 73 additions & 32 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 868b801

Please sign in to comment.