HTML画布的最大大小是多少?(What is the maximum size for an HTML canvas?)

在HTML中创建大型可视化。

在Chrome(第18版)中,最大画布尺寸为32,768像素高。 有没有办法展示更大的画布?

这个限制来自哪里?

Creating a large visualization in HTML.

In Chrome (v. 18), the maximum canvas size is 32,768 pixels high. Is there a way to display a larger canvas?

Where is this limit coming from?

最满意答案

32,768 = 2 152 15 - 1 = 32,767是short int可以容纳的最大数字。

因此,Google Chrome可能会使用数据类型short int来存储<canvas>元素的大小。

如果要显示较大的<canvas>元素,可以尝试使用多个元素。 如果你真的需要~33k像素,你还应该考虑另一种实现技术!

32,768 = 215 and 215 - 1 = 32,767 is the biggest number a short int can hold.

So Google Chrome probably uses the datatype short int for storing the sizes of a <canvas> element.

If you want to display larger <canvas> elements, you could try to use multiple ones. You should also consider another implementation technique if you really need ~33k pixels!

HTML画布的最大大小是多少?(What is the maximum size for an HTML canvas?)

在HTML中创建大型可视化。

在Chrome(第18版)中,最大画布尺寸为32,768像素高。 有没有办法展示更大的画布?

这个限制来自哪里?

Creating a large visualization in HTML.

In Chrome (v. 18), the maximum canvas size is 32,768 pixels high. Is there a way to display a larger canvas?

Where is this limit coming from?

最满意答案

32,768 = 2 152 15 - 1 = 32,767是short int可以容纳的最大数字。

因此,Google Chrome可能会使用数据类型short int来存储<canvas>元素的大小。

如果要显示较大的<canvas>元素,可以尝试使用多个元素。 如果你真的需要~33k像素,你还应该考虑另一种实现技术!

32,768 = 215 and 215 - 1 = 32,767 is the biggest number a short int can hold.

So Google Chrome probably uses the datatype short int for storing the sizes of a <canvas> element.

If you want to display larger <canvas> elements, you could try to use multiple ones. You should also consider another implementation technique if you really need ~33k pixels!