I made this plnkr to demonstrate my problem. I don't understand why the line as drawn looks 'thicker' or 'fatter' when its drawn at an angle rather than straight across page.
How can I draw this shape with consistent line width?
html:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
</head>
<body>
<canvas id="canvas"></canvas>
</body>
<script src="script.js"></script>
</html>
css:
#canvas {
width: 100%;
height: 80px;
border: 1px solid black;
}
js (note that the line width is just set once to '5' before drawing begins).:
(function () {
var canvas = document.getElementById('canvas');
if (!canvas.getContext) {
// browser does not support HTML canvas
return;
}
var ctx = canvas.getContext("2d");
ctx.strokeStyle = "#000000";
ctx.lineWidth = 5;
ctx.beginPath();
ctx.lineTo(0, canvas.height - 10);
var twoThirds= (canvas.width / 3) * 2;
var oneSixth= (canvas.width / 6);
ctx.lineTo(twoThirds, canvas.height - 10);
ctx.lineTo(twoThirds + oneSixth, 5);
ctx.lineTo(canvas.width-3, canvas.height - 10);
ctx.stroke();
})();