首页javascriptdrawing_settingsCanvas - 如何更改画布宽度和高度

Canvas - 如何更改画布宽度和高度

我们想知道如何更改画布宽度和高度。

<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
function zoom(){
    var testcanvas = document.getElementById("canvas");
    testcanvas.width *=1.25;
    testcanvas.height *= 1.25;
}
</script>
  <input type="button" value="zoom" onClick="zoom()" />
  <div class="main">
    <canvas id="canvas" style="background: #ff0000;"></canvas>
  </div>
</body>
</html>