Skip to content

Instantly share code, notes, and snippets.

@jpsilvashy
Created November 20, 2012 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpsilvashy/4120797 to your computer and use it in GitHub Desktop.
Save jpsilvashy/4120797 to your computer and use it in GitHub Desktop.
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