Created
March 10, 2022 08:13
-
-
Save wolf20482/ae3fd1fda1c348d769f656f52fcc521d to your computer and use it in GitHub Desktop.
random colors with mouse
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> | |
<head> | |
<style> | |
html, | |
body { | |
margin: 0 !important; | |
padding: 0 !important; | |
overflow-x: hidden !important; | |
overflow-y: hidden !important; | |
} | |
</style> | |
</head> | |
<body> | |
<canvas id="nft" width="300" height="150" onmousemove="myFunction(event)"> | |
update your browser</canvas> | |
<script> | |
let c = document.getElementById("nft"); | |
c.width = window.innerWidth; | |
c.height = window.innerHeight; | |
let ctx = c.getContext("2d"); | |
function myFunction(e) { | |
ctx.fillStyle = "#" + Math.floor(Math.random() * 16777215).toString(16); | |
let x = e.clientX; | |
let y = e.clientY; | |
ctx.fillRect(x, y, 4, 4); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment