Skip to content

Instantly share code, notes, and snippets.

@samueltcsantos
Forked from anonymous/canvas.js
Last active August 29, 2015 14:12
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 samueltcsantos/4755c252f27c56e1a286 to your computer and use it in GitHub Desktop.
Save samueltcsantos/4755c252f27c56e1a286 to your computer and use it in GitHub Desktop.
var canvas = document.getElementById('mycanvas');
var context = canvas.getContext('2d');
context.strokeStyle = '#0000ff';
context.lineWidth = 2;
context.beginPath();
context.fillStyle = '#00ff00'; //green
context.fill();
context.fillRect(100, 10, 150, 100);
context.fillStyle = '#ffff00'; //yellow
context.fillRect(10, 10, 50, 50);
context.fillStyle = '#ffffff'; //white
context.fillRect(10,10, 30, 30);
context.fillStyle = '#000000'; //black
context.fillRect(200, 180, 30, 30);
context.fillStyle = '#990099'; //purple
context.fillRect(180, 20, 80, 50);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment