I have a situation that I use a canvas element to draw a matrix effect and the color of the matrix code text is brighter and sharper in Firefox than Chrome:
As you can see, the text in Chrome is smoother, with some blur, which is what I want.
HTML5 matrix effect: http://thecodeplayer.com/walkthrough/matrix-rain-animation-html5-canvas-javascript
The only thing I can guess is that maybe Firefox does not like the way the translucent effect is achieved:
//Black BG for the canvas
//translucent BG to show the trail
this.ctx.fillStyle = "rgba(0, 0, 0, 0.05)";
this.ctx.fillRect(0, 0, this.$c.width(), this.$c.height());
this.ctx.fillStyle = this.color; //green text
Why is that happening? Is there a way to fix that kind of behavior in firefox by a proper way other than detecting and setting a different color for each browser?
EDIT:
The drawing code with the translucent effect:
//drawing the characters
function draw()
{
//Black BG for the canvas
//translucent BG to show trail
ctx.fillStyle = "rgba(0, 0, 0, 0.05)";
ctx.fillRect(0, 0, c.width, c.height);
ctx.fillStyle = "#0F0"; //green text
ctx.font = font_size + "px arial";
//looping over drops
for(var i = 0; i < drops.length; i++)
{
//a random chinese character to print
var text = chinese[Math.floor(Math.random()*chinese.length)];
//x = i*font_size, y = value of drops[i]*font_size
ctx.fillText(text, i*font_size, drops[i]*font_size);
//sending the drop back to the top randomly after it has crossed the screen
//adding a randomness to the reset to make the drops scattered on the Y axis
if(drops[i]*font_size > c.height && Math.random() > 0.975)
drops[i] = 0;
//incrementing Y coordinate
drops[i]++;
}
}
setInterval(draw, 33);
Latest firefox version: 49.0.2
EDIT2:
Checked it from another computer with Firefox 39 and an old 17" TFT screen. Firefox still has not the translucent effect and the letters are bright and sharp:
UPDATE:
It appears that this is a Windows Firefox/Chrome behavior and it does not occur on macOS versions. Here is an image link with both browsers opened on macOS Mountain Lion: macOS ML Screenshot
UPDATE2:
After some search and tests, it turns out it is a font issue and how Chrome renders the characters:
To me, that looks like a totally different font. Chrome renders the letters using pointy ends, but Firefox uses a more solid and bold effect. Just tried to change the font on the ctx.font
like ctx.font = "normal normal " + font_size + "px arial"
but it does not make any difference.