My html file is very simple:
<body>
<canvas id="canvas" width="900" height="400"></canvas>
<button onclick="DrawSVG()">Draw SVG</button>
</body>
When click the button I draw the SVG on the canvas, using canvg.js
var opts = {
ignoreMouse: false,
ignoreClear: true,
ignoreDimensions : true,
offsetX: 0,
offsetY: 0
};
canvg(canvas, "face.svg", opts);
face.svg:
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" >
<rect x="0" y="0" width="80" height="80" rx="6" fill="blue" stroke="red" stroke-
width="1px" fill-opacity="0.7" />
</svg>
It seems correct.
But when I define the width and height in the head:
<style type="text/css">
#canvas {
width: 900px;
height: 400px;
}
The svg on the canvas is 4 times larger than before. What's the difference?