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.

How to whitelist website on AdBlocker?

How to whitelist website on AdBlocker?

  1. 1 Click on the AdBlock Plus icon on the top right corner of your browser
  2. 2 Click on "Enabled on this site" from the AdBlock Plus option
  3. 3 Refresh the page and start browsing the site
%d bloggers like this: