javascript-canvas Uncaught Error: INDEX_SIZE_ERR: DOM Exception 1

OK, I have two versions of my code. The first appears to work (mostly) and the 2nd gives me the Uncaught Error in the topic name. defs: var VID_WID = 640; var VID_HIGH = 360; var OUT_WID = 480; var OUT_HIGH = 320; var NUM_WID = 3; var NUM_HIGH = 3; var TILE_WIDTH = VID_WID / NUM_WID; var TILE_HEIGHT = VID_HIGH / NUM_HIGH; var OUT_WIDTH = OUT_WID / NUM_WID; var OUT_HEIGHT = OUT_HIGH / NUM_HIGH; Working: tile.sx = x*TILE_WIDTH; tile.sy = y*TILE_HEIGHT; tile.dx = x*OUT_WIDTH; tile.dy = y*OUT_HEIGHT; ... draw.drawImage(copycanvas, tile.sx, tile.sy, TILE_WIDTH, TILE_HEIGHT, tile.dx, tile.dy, OUT_WIDTH, OUT_HEIGHT); Gets Exception: tile.sx = x; tile.sy = y; tile.dx = x; tile.dy = y; ... draw.drawImage(copycanvas, tile.sx*TILE_WIDTH, tile.sy*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT, tile.dx*OUT_WIDTH, tile.dy*OUT_HEIGHT, OUT_WIDTH, OUT_HEIGHT); The ONLY difference I see is WHERE I am doing the multiply by the WIDTH and HEIGHT parameters. Yet one works and the other gives the exception. I WANT to use the latter code so I can compoare the x and y values of the .sx and .dx directly against x, instead of sx/TILE_WIDTH == dx/OUT_WIDTH. I guess I can always add yet another couple of fields to duplicate the effort, but it seems that I should NOT have to do that. Any idea why one works and the other doesn't?

以上就是javascript-canvas Uncaught Error: INDEX_SIZE_ERR: DOM Exception 1的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏