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
30
31
32
33
34
35
// require https://cdn.jsdelivr.net/npm/p5@latest/lib/p5.js
/* exported preload setup draw*/
// height and width of the image to test
// be careful turning this up, the slow case can be very slow
// with big images
const TEST_SIZE = 200;
let testImage;
function preload() {
testImage = loadImage(`/pixels/sketches/world_200.png`);
}
function setup() {
createCanvas(TEST_SIZE * 3, TEST_SIZE);
noSmooth();
noLoop();
}
function draw() {
let startTime;
let endTime;
background(255);
// draw original image
image(testImage, 0, 0);
// invert with built in get() + set()
const testImageCopy = createImage(TEST_SIZE, TEST_SIZE);
testImageCopy.copy(
testImage,
0,
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
⌥⌘j Open Console | ⌘s/ctrl-s Update Preview |