V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
海外远程工作指南
最全面的海外远程工作指南,帮你看到更多的可能性、少走弯路,最后找到一份如意的远程工作
Promoted by hlwjia
ylsywkd
V2EX  ›  问与答

html canvas 元素的绘图操作是异步的吗?

  •  
  •   ylsywkd · 2015-10-12 22:08:00 +08:00 · 1842 次点击
    这是一个创建于 3572 天前的主题,其中的信息可能已经有所发展或是发生改变。


    var ctx = canvas.getContext('2d');
    for (var i = 0; i < canvas.height; i++) {
    for (var j = 0; j < canvas.width; j++) {
    var r1 = Math.round(Math.random() * 255),
    r2 = Math.round(Math.random() * 255),
    r3 = Math.round(Math.random() * 255);
    ctx.fillStyle = 'rgba(' + r1 + ',' + r2 + ',' + r3 + ',' + '1' + ')';
    ctx.fillRect(j, i, 1, 1);
    }
    }

    图像是一下子渲染出来的,而不是一个个像素出现的。

    目前尚无回复
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5274 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 01:19 · PVG 09:19 · LAX 18:19 · JFK 21:19
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.