<!DOCTYPE html> | |
<canvas id="c"></canvas> | |
<script type="text/javascript"> | |
const color = "rgba(120, 45, 200, 0.7)"; // A kind of half purple | |
const canvas = document.getElementById("c"); | |
const ctx = canvas.getContext("2d"); | |
// Opaque canvases have black backgrounds on pixels that haven't been drawn to | |
ctx.fillStyle = "black"; | |
ctx.fillRect(0, 0, canvas.width, canvas.height); | |
ctx.fillStyle = color; | |
ctx.fillRect(10, 10, 100, 100); | |
</script> | |
</html> |