V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
ylsywkd
V2EX  ›  问与答

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

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


    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   ·   我们的愿景   ·   实用小工具   ·   3408 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 11:54 · PVG 19:54 · LAX 04:54 · JFK 07:54
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.