Skip to content

Instantly share code, notes, and snippets.

@thinkerbot
Created March 19, 2010 16:36
Show Gist options
  • Save thinkerbot/337792 to your computer and use it in GitHub Desktop.
Save thinkerbot/337792 to your computer and use it in GitHub Desktop.
a test of html5 canvas element
<html>
<body>
<!-- Test how supportive a browser is of several rendering techniques. -->
<p id="text">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut
labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in
voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat
non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
<canvas id="canvas" width="200" height="200">
<p>Your browser doesn't support canvas.</p>
</canvas>
<script type="text/javascript">
var context = document.getElementById('canvas').getContext('2d');
context.fillStyle = "rgb(0,0,0)";
context.fillRect(30, 30, 50, 50);
</script>
<script type="text/javascript">
var text = document.getElementById('text');
var output = document.createElement("p");
output.appendChild(document.createTextNode("(x, y, height, width) = (" + text.offsetLeft + ", " + text.offsetTop + ", " + text.offsetHeight + ", " + text.offsetWidth + ")"));
var canvas = document.getElementById('canvas')
document.body.insertBefore(output, canvas);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment