Skip to content

Instantly share code, notes, and snippets.

@mattcodez
Created November 26, 2014 06:51
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 mattcodez/c7b35f8aabe2193ce4dc to your computer and use it in GitHub Desktop.
Save mattcodez/c7b35f8aabe2193ce4dc to your computer and use it in GitHub Desktop.
Simple function to write a single pixel to a canvas element
//Copied from http://stackoverflow.com/q/4899799/119909
function pixel(x,y){
d[0] = 255;//r
d[1] = 0;//g
d[2] = 0;//b
d[3] = 255;//a
ctx.putImageData( id, x, y );
}
var ctx = document.getElementById('c').getContext('2d');
var id = ctx.createImageData(1,1);
var d = id.data;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment