'use strict';
{
function draw() {
const canvas = document.querySelector('canvas');
if (typeof canvas.getContext === 'undefined') {
return;
}
const ctx = canvas.getContext('2d');
// ctx.fillRect(50, 50, 50, 50);
ctx.strokeRect(50, 50, 50, 50);
}
draw();
}
body {
background: #222;
}
canvas {
background: #fff;
}
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>My Canvas</title>
<link rel="stylesheet" href="css/styles.css">
</head>
<body>
<canvas width="600" height="240">
Canvas not supported.
</canvas>
<script src="js/main.js"></script>
</body>
</html>