Skip to content

Instantly share code, notes, and snippets.

@SuzanaK
Created March 3, 2013 05:40
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 SuzanaK/5074699 to your computer and use it in GitHub Desktop.
Save SuzanaK/5074699 to your computer and use it in GitHub Desktop.
HTML5 Canvas Minimal Excample
<script>
var canvas = document.getElementById('mycanvas');
var ctx = canvas.getContext('2d');
ctx.beginPath();
ctx.moveTo(startX, startY);
ctx.lineCap = 'round';
ctx.lineWidth = 3;
var red = (((Math.random() * 64) + 128) >> 0);
var green = (((Math.random() * 64) + 128) >> 0);
var blue = (((Math.random() * 64) + 128) >> 0);
ctx.strokeStyle = 'rgb(' + red + ',' + green + ',' + blue + ')';
var newX = startX;
var newY = startY - STEP_SIZE;
ctx.lineTo(newX, newY);
ctx.stroke(); // nur am Ende
</script>
<canvas id="mycanvas" width=2800, height=2260>Your browser doesn't support the HTML5 canvas element. Please install a decent browser (e.g. Firefox)</canvas>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment