Here is the piece of code that helps you to update a function at certain interval of time. The time is usually calculated in milliseconds. As you can see the code has 1000 somewhere in the setinterval function. This code helps to call the function every second. Here in the first line you can see the ‘mainCanvas’. It is nothing but the id of HTML5 canvas.
var drawingCanvas = document.getElementById(‘mainCanvas’);
/* Initaliase a 2-dimensional drawing context */
var context = drawingCanvas.getContext(‘2d’);
//call the function which you want to update.
All right test the code and see the result. Happy Coding….
As in previous blog you can find the code for pixel drawing code. Here is the link for the pixel drawing code. http://bit.ly/Wzm0xG
Go through it and happy coding…
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.
var c1 = document.getElementById(“mainCanvas”);
var rContext = c1.getContext(“2d”);