首页 > html5 canvas的宽高有大小限制吗?

html5 canvas的宽高有大小限制吗?

我写了一个js将一个包含流程信息的json字符串转换成流程图输出,canvas根据流程图需要大小计算出自己的宽高,再在算好宽高的canvas上画流程图,如下图

现在的问题是如果流程复杂,end活动太多,导致canvas宽度过大,就画不出来任何图形了。


请问你做过html5的离线缓存没


我在stackoverflow找到答案了:

canvas的大小有限制,而且浏览器或者设备不同,其限制还不一样。

翻译:
截至2012年7月,Safari上第三代iPad最大6826像素高度的canvas。Internet Explorer 9的最大高度为8192像素。(我认为的最大宽度是相同的,但没有测试这个。)  

超过最大宽度使得在Safari iPad上的画布无用,没有什么会被画出来。Internet Explorer 9仍将使用可用的8192像素,但不会超出范围的画。

我没有在其他浏览器测试特定的上限,但最新版本的Safari(Mac)和Safari,Chrome,Firefox(Windows)都允许至少8192像素。

原文:
As of July 2012, Safari on a 3rd generation iPad has a maximum canvas height of 6826 pixels. Internet Explorer 9 has a maximum height of 8192 pixels. (I assume the maximum widths are the same, but have not tested this.)

Exceeding the maximum width in Safari on iPad renders the canvas useless; nothing will draw. Internet Explorer 9 will still use the available 8192 pixels, but will not draw outside that range.

I have not tested for specific upper limits on other browsers, but the latest versions of Safari (Mac) and Safari, Chrome, and Firefox (Windows) all allow at least 8192 pixels.

摘自答案地址


html5没有对canvas的宽高做限制啊。一般都是先定义好了canvas的宽高再绘图的吧,所以你的问题应该就是绘图区域超过了定义好的舞台的宽高了吧。


没有限制,先定义好,在绘图,如楼上


一般表格、图这种都是都是用SVG吧

【热门文章】
【热门文章】