console
var canvas = document.querySelector("#canvas");
let w = 600, h = 600;
let ctx = canvas.getContext("2d");
let zhujsize = 600 / 30;
for (var i = 0; i < 3; i++) {
name(i, zhujsize);
}
function name(x, y) {
if (canvas.getContext) {
ctx.beginPath();
var wei = y / 2;
ctx.arc(zhujsize * i + wei + 1, zhujsize, wei, 0, 2 * Math.PI);
ctx.fillStyle = "#ff7676";
ctx.fill();
ctx.strokeStyle = "blue";
ctx.stroke();
}
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>贪吃蛇小游戏</title>
</head>
<body>
<h1>贪吃蛇小游戏</h1>
<canvas width="600" height="600" id="canvas"></canvas>
</body>