On what are seemingly random occasions, the color of HTML canvas elements appear lighter than they are actually supposed to be. In the code snippet below, I set both the outline and fill to "red", which is supposed to be a valid CSS color corresponding to #ff0000, but under close inspection, the color of the outline is #ff8080. Why does this happen?
In addition, while the reproducible example was only on a outline, I initially saw this happen when I tried to create a black rectangle (#000) and it was gray. (#808080)
Is there a canvas context setting for this? Perhaps a rendering error?
render()
function render() {
var canvas = document.createElement("canvas")
canvas.width = 100
canvas.height = 100
console.log("created canvas",canvas)
// CREATE CONTEXT
var context = canvas.getContext("2d")
console.log("created context",context)
context.strokeStyle = "red"
context.strokeRect(10,10,50,50)
context.fillStyle = "red"
context.fillRect(12.5,12.5,45,45)
document.body.appendChild(canvas)
}