Created
November 26, 2014 06:51
-
-
Save mattcodez/c7b35f8aabe2193ce4dc to your computer and use it in GitHub Desktop.
Simple function to write a single pixel to a canvas element
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
//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