mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-07-03 03:56:26 +02:00
Added test page for webGL - it is also working with the webExtension.
This commit is contained in:
parent
0f35d762e2
commit
f70380aa67
3 changed files with 24 additions and 2 deletions
22
test/webGL-Test.html
Normal file
22
test/webGL-Test.html
Normal file
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test</title>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="canvas" width="10" height="10"></canvas>
|
||||
<span id="output"></span>
|
||||
<script>
|
||||
(function(){
|
||||
var canvas = document.getElementById('canvas');
|
||||
var gl = canvas.getContext('webgl');
|
||||
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);
|
||||
}());
|
||||
</script>
|
||||
</body></html>
|
Loading…
Add table
Add a link
Reference in a new issue