0

I'm trying to build a background with moving stars for a website, by following this example http://timothypoon.com/blog/2011/01/19/html5-canvas-particle-animation/ .

I managed to make it work, but there is a slight problem to it. Whenever I resize the page, I want it to look pretty much the same, with no visible difference. Right now, the page flickers because of the for that I'm using for redrawing the page whenever I resize it.

My question is how do I get rid of that flicker, and, carefully, without remaining with any blank space with no stars when I make the window bigger.

This is the code responsible for resizing:

$(window).resize(function(){
    WIDTH = $(window).width();
    HEIGHT = $(window).height();
    canvas = document.getElementById('pixie');
    $(canvas).attr('width', WIDTH).attr('height',HEIGHT);
    $('.container').width(WIDTH).height(HEIGHT);
    for(var i = 0; i < 1000; i++) {
        pxs[i] = new Circle();
        pxs[i].reset();
    }
    setInterval(draw,rint);
})
Radu
  • 524
  • 1
  • 6
  • 19
  • 1
    The developer mentioned this issue: "... some people out there will see some flickering when viewing the demo ...". http://timothypoon.com/blog/2011/01/19/html5-canvas-particle-animation/ He wrote that you can find the answer here: http://stackoverflow.com/questions/2795269/does-html5-canvas-support-double-buffering – Wissam El-Kik May 22 '14 at 08:37
  • Thank you, now I have to read that solution :) – Radu May 22 '14 at 09:21

0 Answers0