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);

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s