小编Kaz*_*Kaz的帖子

使用image.onload将多个图像绘制到画布上

在尝试将大型2D图像数组绘制到画布上时,我遇到了问题.使用一个单独的程序,我正在拍摄一个大的图像文件并将其分解成更小,更均匀的部分.我正在使用2D数组来表示图像的这个"网格",理想情况下,当我在网格中分配每个元素的src时,该图像一旦准备就会被绘制到画布上的正确点.但是,我的代码无效.

var grid = new Array()  
/*grid is set to be a 2D array of 'totalRows' rows and 'totalCols' columns*/  

/*In the following code, pieceWidth and pieceHeight are the respective height/widths  
of each of the smaller 'pieces' of the main image. X and Y are the coordinates on  
the canvas that each image will be drawn at. All of the images are located in the  
same directory (The src's are set to http://localhost/etc), and each individual  
filename is in the …
Run Code Online (Sandbox Code Playgroud)

html5 canvas javascript-events onload

6
推荐指数
1
解决办法
7302
查看次数

标签 统计

canvas ×1

html5 ×1

javascript-events ×1

onload ×1