-
-
Save davidguttman/af34fc391c47baed93a463b3c2b40bc8 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
<div id='colorsquare3'></div> | |
<script> | |
var cs3 = window.colorsquare3 | |
cs3.style.cssText = ` | |
width: 200px; | |
height: 200px; | |
border: 2px solid black; | |
` | |
window.addEventListener('mousemove', function (evt) { | |
var x = evt.clientX / window.innerWidth | |
var y = evt.clientY / window.innerHeight | |
var hue = Math.round(y * 360) | |
var light = Math.round(x * 100) | |
var w = `${x * 200}px` | |
var h = `${y * 200}px` | |
var trans = `rotate(${x * 360}deg)` | |
var color = `hsl(${hue}, 100%, ${light}%)` | |
cs3.style.background = color | |
cs3.style.width = w | |
cs3.style.height = h | |
cs3.style.transform = trans | |
}) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment