Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple device orientation to RGB color
<!DOCTYPE HTML>
<html>
<head>
<title>Device Orientation</title>
</head>
<body>
<script src="http://d3js.org/d3.v2.js"></script>
<script>
function handleOrientation(orientData) {
var color = d3.rgb(orientData.alpha, orientData.beta, orientData.gamma)
d3.select("html").style("background", color);
}
window.addEventListener("deviceorientation", handleOrientation, true);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment