标题:JS绘画几个图片有无简单的方法??????
取消只看楼主
vivi1983
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2017-11-7
 问题点数:0 回复次数:0 
JS绘画几个图片有无简单的方法??????
像以下代码,绘画几个图,十烦锁,有无简洁的写洁啦???????
   
        var conx = document.getElementById("canvas_id");
        var gg = conx.getContext("2d");
        var left = [];
        left[0]= new Image();
        left[1]= new Image();
        left[2]= new Image();
        left[0].src="left0.png"
        left[1].src="left1.png"
        left[2].src="left2.png"
        
        
        left[0].onload=function(){
           
            gg.drawImage(left[0],0,0,32,32);
        }
        left[1].onload=function(){
           
            gg.drawImage(left[1],0,100,32,32);
        }
            left[2].onload=function(){
           
            gg.drawImage(left[2],0,200,32,32);
            
            

[此贴子已经被作者于2017-11-8 19:06编辑过]

搜索更多相关主题的帖子: JS left new Image onload 
2017-11-07 15:53



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-482215-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017877 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved