无法使黑色画布显示在屏幕上

时间:2019-05-21 20:41:01

标签: javascript html html5-canvas

我正在尝试为正在制作的乒乓球游戏绘制黑色画布,但无法在屏幕上绘制

我已经检查过控制台,没有错误

// select the canvas that we have made in our html file
const cvs = document.getElementById("pong");
const ctx = cvs.getContext("2d");

// draw our rectangle function 

function drawRect(x, y, w, h, color) {
  ctx.fillStyle = color;
  ctx.fillRect(x, y, w, h);
}

drawRect(0, 0, cvs.wdith, cvs.height, "BLACK");
<canvas id="pong" width="600" height="400"></canvas>

0 个答案:

没有答案