Drawing a single pixel on Javascript

well after a long procedure and searching for a whole day to draw a single pixel on a HTML5 canvas, this code as I wrote worked out to draw a single pixel.

function drawpix(x,y){

   var c1 = document.getElementById(“mainCanvas”);
   var rContext = c1.getContext(“2d”);
   rContext.beginPath();
   rContext.moveTo(x,y);
   rContext.lineTo(x+1,y+1);
   rContext.closePath();
   rContext.strokeStyle= ‘white’;
   rContext.stroke();
  

}

drawpix(10,10);

Leave a Reply

Your email address will not be published. Required fields are marked *