-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathfill.js
More file actions
29 lines (22 loc) · 815 Bytes
/
fill.js
File metadata and controls
29 lines (22 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import {Image} from '../ImageScript.js';
import {equals} from "@std/bytes";
const panic = message => {
console.error(message);
process.exit(1);
};
(async () => {
{
const image = new Image(512, 512);
image.fill(0xff8000ff);
const encoded = await image.encode();
const target = await Deno.readFile('./tests/targets/fill-static.png');
if (!equals(encoded, target)) panic('fill static doesn\'t equal');
}
{
const image = new Image(512, 512);
image.fill((x, y) => Image.hslToColor((x + y) / (image.width + image.height), 1, .5));
const encoded = await image.encode();
const target = await Deno.readFile('./tests/targets/fill-func.png');
if (!equals(encoded, target)) panic('fill func doesn\'t equal');
}
})();