我试图填写三张Canvas图纸中的第一张图片的背景,但无法显示任何内容。
HTML:
<!DOCTYPE html>
<html>
<head>
<script src="lab5.js"> </script>
<title> Lab 5 </title>
</head>
<body>
<h1> Canvas </h1>
<canvas id="drawingSurface1" width="700" height="500" style="border:1px solid #000000;">
</canvas>
<canvas id="drawingSurface2" width="350" height="500" style="border:1px solid #000000;">
</canvas>
<canvas id="drawingSurface3" width="350" height="500" style="border:1px solid #000000;">
</canvas>
</body>
</html>
使用Javascript:
// drawing 1
function drawing1() {
var drawingSurface=document.getElementById("drawingSurface1");
var ctx = drawingSurface.getContext("2d");
ctx.fillStyle="#FF0000";
}
// drawing 2
function drawing2() {
var drawingSurface=document.getElementById("drawingSurface2");
var ctx = drawingSurface.getContext("2d");
}
// drawing 3
function drawing3() {
var drawingSurface=document.getElementById("drawingSurface3");
var ctx = drawingSurface.getContext("2d");
}
我知道我可能错过了一些非常简单的事情,但我的思绪一片空白。