Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 Canvas: How to know the limit for the size?

I have a canvas that is 1400px wide and around 12000px long. I have a hierarchy diagram that I need to draw. When it is expanded fully, it takes up the entire canvas (the size that I have set).

Now this works fine when I access the page from laptop (on various browsers).

But when I access it fron Safari on iPad, the canvas does not show up, or the content on the canvas is not visible. I think, this is due to the large size of the canvas.

So, it seems, memory availability or device dependency is there, that limits the size (withing the allowed size as per W3C).

How to know or calculate the size? Or is there some workarounds? Is there any other way round? I am a beginner.

like image 555
Kangkan Avatar asked Apr 03 '12 07:04

Kangkan


People also ask

Which parameters are used to specify a canvas size to ensure it best fits the size of the screen in an HTML5 document?

The width attribute specifies the width of the <canvas> element, in pixels. Tip: Use the height attribute to specify the height of the <canvas> element, in pixels.

When a canvas element exceeds the maximum size for the browser?

We can create canvas elements that exceed 4096 pixels in width or height as long as the total amount of pixels is below 16777216. const canvas = document.

How do I change the canvas size in HTML5?

Canvas has two sizes, the size of the element and the size of the drawing surface. The default size for both element and drawing surface is 300 x 150 screen pixels. To set the height and width canvas HTML5 has two attributes: Height: With the help of Height attribute we can set the height.


1 Answers

Alternative ways (anwsering the comment):

  1. use multiple canvases (one for each depth level)
  2. use an image rendered on-the-fly by the backend (php? ruby? python? java?)
  3. use multiple divs styled with CSS (cool & lightweight solution)
  4. render several small images and position them with CSS (mix of #2 and #3)

These are just proposals, not tested on real data.

like image 170
Artur Czajka Avatar answered Oct 03 '22 01:10

Artur Czajka