How to avoid HTML Canvas auto-stretching

前端 未结 5 1562
盖世英雄少女心
盖世英雄少女心 2021-01-01 11:12

I have the following piece of HTML:



&l         


        
5条回答
  •  Happy的楠姐
    2021-01-01 12:07

    I found it easier to just put a while loop waiting for timeout within my animation loop, For example:

    function animate() {
        c.clearRect(0, 0, window.innerWidth, window.innerHeight);
        ryuji.draw();
        ryuji.update();
        let now = Date.now();
        then = now + (1000 / fps);
        while (Date.now() < then) {
    
        }
        requestAnimationFrame(animate);
    }
    

提交回复
热议问题