Created
March 19, 2019 06:28
-
-
Save xhackjp1/de1a367a12aaaad51ac995d5e206f331 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="ja"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Canvas tutorial template</title> | |
<script type="text/javascript"> | |
var n = 0; | |
var canvas = document.getElementById('tutorial'); | |
function init() { | |
draw(); | |
setInterval(draw, 33); | |
} | |
/* fillRect()の例 */ | |
function draw() { | |
var ctx = canvas.getContext('2d'); | |
ctx.beginPath(); | |
ctx.fillRect(20, 20, 80 + n, 40 + n); | |
ctx.fillStyle = `rgb(255, ${(2*n) % 255}, 0)`; | |
n = n + 1; | |
} | |
</script> | |
<style type="text/css"> | |
canvas { | |
background-color: #fff; | |
border: 1px solid #999; | |
} | |
</style> | |
</head> | |
<body onload="init();"> | |
<canvas id="tutorial" width="800" height="800"></canvas> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment