I have a yellow canvas, inside which I draw a red rectangle. But I noticed an interesting effect - the two sides of the rectangle that are on the border have very specific edges, and the two sides of the rectangle that are inside the yellow canvas are “softened” or “blurred”.
This is what I have now:

My HTML:
<canvas id="myCanvas">
</canvas>
JavaScript:
var canvas=document.getElementById("myCanvas");
var ctx=canvas.getContext("2d");
ctx.fillStyle="#FF0000";
ctx.fillRect(0,0,150,75);
CSS
#myCanvas {
background-color:#FFFF00;
width:1000px;
height:600px;
border: none;
margin-left:auto;
margin-right:auto;
}
JSFIDDLE
Why is this happening? And how can I make all four sides of a rectangle very precise and defined? Thank.
source
share