mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-07-04 20:46:39 +02:00
Test cleanup.
This commit is contained in:
parent
d8f6fb1ac9
commit
7d0c9681df
11 changed files with 437 additions and 395 deletions
18
test/webGL-Test.js
Normal file
18
test/webGL-Test.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
(function(){
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.width = 11;
|
||||
canvas.height = 13;
|
||||
var gl = canvas.getContext('webgl');
|
||||
|
||||
// paint it completely black
|
||||
gl.clearColor(0, 0, 0, 1);
|
||||
gl.clear(gl.COLOR_BUFFER_BIT);
|
||||
|
||||
var pixels = new Uint8Array(gl.drawingBufferWidth * gl.drawingBufferHeight * 4);
|
||||
gl.readPixels(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
|
||||
var values = {};
|
||||
for (var i = 0; i < pixels.length; i += 1){
|
||||
values[pixels[i]] = (values[pixels[i]] || 0) + 1;
|
||||
}
|
||||
document.getElementById("output").textContent = JSON.stringify(values);
|
||||
}());
|
Loading…
Add table
Add a link
Reference in a new issue