Created
February 28, 2013 02:19
-
-
Save ericevenchick/5053655 to your computer and use it in GitHub Desktop.
A simple html5 gauge.
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> | |
</head> | |
<body> | |
<canvas id='gauge' width=400 height=400> | |
<script> | |
drawGauge = function(canvasId, angle, length) { | |
var gaugeCanvas = document.getElementById(canvasId); | |
var ctx = gaugeCanvas.getContext('2d'); | |
ctx.beginPath(); | |
ctx.moveTo(200,400); | |
ctx.lineTo((200 - length*Math.cos(angle)), (400 - length*Math.sin(angle))); | |
ctx.stroke(); | |
ctx.closePath(); | |
} | |
drawGauge('gauge', Math.PI/4, 130); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment