【发布时间】:2018-07-11 20:40:44
【问题描述】:
我有不同尺寸的图像,我试图将它们用作画布上的背景。
index.html:
<!DOCTYPE html>
<html>
<head>
<title>js</title>
</head>
<body onLoad='init2()'>
<canvas id="canvas" width="1000" height="1000">
This text is displayed if your browser does not support HTML5 Canvas.
</canvas>
<!-- This image will be displayed on the canvas -->
<img id="myImage" src="https://image.slidesharecdn.com/bareconf-140329111624-phpapp02/95/draft-scientific-paper-1-638.jpg?cb=1396091812" style = "display: none">
</body>
</html>
如何将所有图像调整为固定的画布尺寸? 这是完整的code。
当我更改为 image 时,它不会调整到我的画布尺寸。
调整所有图像或画布的大小哪个更好?
【问题讨论】:
-
您是否关心保持图像的纵横比?
-
"哪个更好,调整我的所有图像或画布的大小?"看你想做什么
标签: javascript html canvas html5-canvas