Skip to content

Instantly share code, notes, and snippets.

@ahndmal
Created August 16, 2025 11:52
Show Gist options
  • Save ahndmal/5158b5a0edbffd090ef66aef5eb1303d to your computer and use it in GitHub Desktop.
Save ahndmal/5158b5a0edbffd090ef66aef5eb1303d to your computer and use it in GitHub Desktop.
<!doctype html>
<html lang="en-US">
<head>
<meta charset="utf-8" />
<title>Canvas tutorial</title>
<style>
canvas {
border: 1px solid black;
}
</style>
</head>
<body>
<canvas id="canvas" width="150" height="150"></canvas>
<script>
function draw() {
const canvas = document.getElementById("canvas");
if (canvas.getContext) {
const ctx = canvas.getContext("2d");
}
}
window.addEventListener("load", draw);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment