W3C home > Mailing lists > Public > www-svg@w3.org > October 2003

Re: Unit conversion of percentage values in the SVG DOM

From: Steve Schafer <steve@fenestra.com>
Date: Mon, 06 Oct 2003 12:48:39 -0400
To: www-svg@w3.org
Cc: Dean Jackson <dean@w3.org>
Message-ID: <2373ov07tshet20l5ung46oa0co57imqfa@4ax.com>

On Tue, 7 Oct 2003 01:18:52 +1000, Dean Jackson <dean@w3.org> wrote:

>nearly ancient history, but better late than never....

I'm hoping that my other correspondents also subscribe to that
philosophy, as I, too, have a number of stale emails in my inbox
awaiting my replies....

>The enclosing viewport of the <rect> is defined by the <symbol>.

Exactly. That's the problem. The enclosing viewport is defined by the
symbol, but the dimensions of that viewport are determined at the
symbol's point of USE, not the point of its DEFINITION. (This follows
from the semantics of the <use> element as described in SVG 1.1 section
5.6.) Thus, you can't (meaningfully) convert a percentage to an absolute
length on any elements contained within a <symbol> element, because the
<symbol> element provides only the definition of the symbol, and not the
context of its use.

Here's a concrete example:

 <svg width="8cm" height="8cm" version="1.1"
     <symbol id="mySymbol">
       <rect x="25%" y="25%" width="50%" height="50%"/>
   <use x="2cm" y="1cm" width="4cm" height="2cm"
   <use x="2cm" y="5cm" width="2cm" height="2cm"

Here, the same symbol is used in two different contexts, and the
interpretation of "x='25%'" on the <rect> contained within the symbol is
different in those two contexts. In the first case, 25% resolves to 1cm,
while in the second it resolves to 0.5cm. And similarly for the width
attribute: 2cm vs. 1cm.

>I thought you said the 25% was displayed as 2cm.

No, I had said that the _width_ of the rectangle in the original code
snippet is displayed as 2cm; the x is displayed as 1cm.

Steve Schafer
Fenestra Technologies Corp
Received on Monday, 6 October 2003 12:49:09 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:53:59 UTC