ISSUE-2378 (autoscale property): Consider adding a property for autoscaling [SVG 2]

ISSUE-2378 (autoscale property): Consider adding a property for autoscaling [SVG 2]

http://www.w3.org/Graphics/SVG/WG/track/issues/2378

Raised by: Doug Schepers
On product: SVG 2

Currently, the way to make an SVG autoscaling is to used percentages instead of specifying a fixed width and height, and to define the dimensions in the viewBox.  

For example, instead of 
  width="600" height="400"   
using
  width="100%" height="100%" viewBox="0 0 600 400"

While logical, this is not always intuitive or convenient.  Common authoring tools (Inkscape, Illustrator) typically default to a fixed width and height, and this seems to resonate with designers' expectations.

Another problem arises with the negotiations of intrinsic width and height when embedding SVG as an images, with an object, etc. in HTML.  Defining this has been tricky, and it's not always implemented correctly.

The combination of width, height, viewBox, and preserveAspectRatio is powerful, but the simplest (and far far most common) cases could be solved by adding a shorthand presentation property for the svg root, 'scaling', with values like 'auto', 'fixed', and so forth.  

Obviously, we would still need to honor the traditional way of making autoscaling images, and to define precisely how this new attribute would interact with all the combinations of width, height, viewBox, and preserveAspectRatio.  To match legacy content, the default value would be 'fixed'.  

The advantage of making it a property would be that this could easily be applied via a stylesheet to all the existing SVG content which isn't defined to autoscale, and it would override the existing behavior.  It would be more easy for authoring tools to add this than the current method.  It could be toggled on and off easily, as well.

Here are some examples of an autoscaling SVG using this attribute would :
 <svg width="600" height="400" viewBox="0 0 600 400" scaling="auto">
 <svg width="600" height="400" viewBox="0 0 1200 800" scaling="auto">
 <svg width="100%" height="100%" viewBox="0 0 600 400" scaling="auto">

This last example would obviously do nothing more than what is done today.  Perhaps for simplicity's sake we could define the property such that it only has an effect on an SVG which doesn't have percentages for values of width and/or height.

Received on Saturday, 18 September 2010 11:48:49 UTC