Svg view permission limitations

I was wondering if there are any hard limits for the svg element viewport. I see strange clipping when I reach very low values ​​(say when the vb width is around .002) or very large, Firefox starts to play funny around 200000000 width.

Is there a rule of thumb somewhere where I can find the current limits?

Try it here: var dim = 0.00002;

http://jsfiddle.net/7v36sLj8/13/

You will see funny things that start happening from this dimming, you can shrink it 10x or enlarge it 10x.

Thanks for the answers, I'll just take min / maxes for the lowest common denominator, which now looks like ffox. (thanks for the answers, also Rob's answer explains why ffox has a much lower threshold for linux / osx).

+3


source to share


2 answers


Firefox originally used a graphics library called cairo to perform cross-platform graphics. Cairo allows only ones to have 32 bits of binary precision fixed point, so Firefox chose 24 bits before the binary point and 8 bits of the binary fraction. So the maximum coordinates are then 2 ^ 24 and the smallest delta is 1/256.



Firefox replaces cairo with more direct platform rendering, eg. Direct2D on Windows, which is now used instead of Cairo if you have a hardware accelerated graphics chip and have hardware acceleration. The platform libraries have no cairo range limitation, but seem to have their own large coordinates bugs.

+3


source


The specification requires browsers to support single precision floating point numbers. The browser is encouraged to use double precision numbers for some calculations, mainly matrix conversions, where small decimal places are often important, but the general rule is the standard C ++ "float" data type.

From http://www.w3.org/TR/SVG11/types.html#Precision :

4.3 Real number accuracy

Unless otherwise noted for a particular attribute or property, a has capacity for at least a single precision floating point number and has a range (minimum) of -3.4e + 38F to + 3.4e + 38F.

It is recommended that high precision floating point storage and computation be performed on operations such as coordinate system transformations to ensure the best precision and prevent rounding errors.

Conforming high quality SVG viewers should use at least a double precision floating point for intermediate computations on certain numeric operations.



How does this relate to your problem?

A value of 0.002 shouldn't be a problem at all. Numbers like 200,000,000 will only be a problem when you need penalty decimals. If your viewbox was "200000000 200000000 0.002 0.002"

- in other words, a very small range of very large numbers - then floating point precision would likely be an issue. However, if there is a problem with large numbers with low precision, or with decimal places that can be accurately encoded with floats, then the browser is out of spec.

The browser may be trying to flatten the shapes, but it rounds to the nearest custom block, rather than rounds to the nearest display pixel. Can you put together a simple example to demonstrate the specific problems you see?

+3


source







All Articles