body {
background-color:black;
}
#myCanvas {
background-color:rgba(55,23,88,0.5); // (bg_R,bg_V,bg_B,bg_A)
}
var myCanvas= document.getElementById("myCanvas");
gl = myCanvas.getContext("webgl", {
premultipliedAlpha: true ,
alpha:true
});
gl.clearColor(0.8, 0, 0, 0.5); // (ccR,ccV,ccB,ccA)
gl.clear(gl.COLOR_BUFFER_BIT);
Now i am looking the color of the resulting canvas :
rvba = 222,8,33,255
var myCanvas= document.getElementById("myCanvas");
gl = myCanvas.getContext("webgl", {
premultipliedAlpha: true ,
alpha:true
});
gl.clearColor(0.8, 0, 0, 0.5);
gl.clear(gl.COLOR_BUFFER_BIT);
var pixels = new Uint8Array( 4);
gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
console.log(pixels); // Uint8Array
* {
margin:0;
}
body {
background-color:black;
}
#myCanvas {
background-color:rgba(55,23,88,0.5);
}
<canvas id="myCanvas" ></canvas>
What is the formula ? (final_R,final_V,final_B,final_A) = function ( bg_R,bg_V,bg_B,bg_A,ccR,ccV,ccB,ccA) ?
and furthermore, if premultipliedAlpha is set to false, how this function change ?
Thanks !
edit : oups...i read the result color of the canvas in a screenshot...but the values change each time, now i have rvba = 227,0,20,255
OK..the screenshot was a very strange idea...now i use gl.readpixel, and i've got : [204, 0, 0, 128]
So, with this very different result, my question is out of date.
Sorry !