v1
11/17/2024 by mikecat -00
Setup HTML - click to add setup HTML
disable setup JavaScript
Setup JavaScript
const width = 1280;
const height = 720;

const targetR = 128;
const targetG = 128;
const targetB = 128;
const targetSize = 2;

const data = new Uint8ClampedArray(width * height * 4);
for (let i = 0; i < data.length; i++) {
	data[i] = ~~(Math.random() * 256);
}

const hitArray = new Uint8Array(1 << 24);
const rMin = Math.max(0, targetR - targetSize);
const rMax = Math.min(255, targetR + targetSize);
const gMin = Math.max(0, targetG - targetSize);
const gMax = Math.min(255, targetG + targetSize);
const bMin = Math.max(0, targetB - targetSize);
const bMax = Math.min(255, targetB + targetSize);
for (r = rMin; r <= rMax; r++) {
	for (g = gMin; g <= gMax; g++) {
		for (b = bMin; b <= bMax; b++) {
			hitArray[r | (g << 8) | (b << 16)] = 1;
		}
	}
}
 
delete caserun single casemove downdrag and drop case


ready



let count = 0;
for (let i = 0; i < data.length; i += 4) {
	if (
		targetR - targetSize <= data[i] && data[i] <= targetR + targetSize &&
		targetG - targetSize <= data[i + 1] && data[i + 1] <= targetG + targetSize &&
		targetB - targetSize <= data[i + 2] && data[i + 2] <= targetB + targetSize
	) {
		count++;
	}
}
delete caserun single casemove updrag and drop case


ready



let count = 0;
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
for (let i = 0; i < data.length; i += 4) {
	count += hitArray[dataView.getUint32(i, true) & 0xffffff];
}

Test Case - click to add another test case
Teardown JS - click to add teardown JavaScript
Output (DOM) - click to monitor output (DOM) while test is running
RUN