Code
Execute
<!DOCTYPE html> <html> <body> <title>wikitechy-HTML Canvas createImageData()</title> </head> <body> <h1>wikitechy-HTML Canvas createImageData() with example: </h1> <canvas id="wikitechyCanvas" width="500" height="250" style="border:1px solid #d3d3d3;"> </canvas> <script> var canvas = document.getElementById("wikitechyCanvas"); var abc = canvas.getContext("2d"); var imgData = abc.createImageData(200, 200); var j; for (j = 0; j < imgData.data.length; j += 4) { imgData.data[j+0] = 0; imgData.data[j+1] = 0; imgData.data[j+2] = 255; imgData.data[j+3] = 255; abc.putImageData(imgData, 60, 30); } </script> </body> </html>
Result