1

everything says "even-width lines don't have this problem" but they DO
here's my code:

var c = document.getElementById("clamvas");
var ctx = c.getContext("2d");
ctx.lineWidth = 2;
ctx.moveTo(0, 0);
ctx.lineTo(1728, 877);
ctx.stroke();
canvas
{
 width:90%;
 height:90%;
 padding: 0;
    margin: auto;
    display: block;
 border:5px solid #000000;
 position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
}
<canvas id="clamvas"></canvas>
OwOstrich
  • 23
  • 6

1 Answers1

1

That's because you're setting width and height through css; that just stretches the canvas element including it's contents.

Use width and height attributes to properly size a canvas element:

var c = document.getElementById("clamvas");
var ctx = c.getContext("2d");
ctx.lineWidth = 2;
ctx.moveTo(0, 0);
ctx.lineTo(1728, 877);
ctx.stroke();
canvas {
    padding: 0;
    margin: auto;
    display: block;
    border:5px solid #000000;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
}
<canvas id="clamvas" wdith="200" height="200"></canvas>
tosi
  • 611
  • 9
  • 24