- From: Jeff Schiller <codedread@gmail.com>
- Date: Wed, 20 Jan 2010 11:04:27 -0600
- To: Dirk Schulze <vbs85@gmx.de>
- Cc: www-svg <www-svg@w3.org>
Please ignore my 'scaling' comment above. I re-read http://www.w3.org/TR/SVG11/struct.html#UseElement and it seems that the <use>'s width/height attributes are ignored when not referencing a <symbol> or a <svg> element. Changing width/height in my test case had no observable effect. I also clearly didn't think when I said "huh?" with respect to WebKit's results, since in looking things over and thinking about what Dirk said, I would say WebKit's (probably non-compliant) implementation of getBBox() is more useful than the other implementations I have been testing. From WebKit's version, I know directly that the bounding box of the drawn contents of the <use> element is (300,300)->(500,400). This is exactly what has been painted. In Firefox/Opera/Batik, I would have to get the bbox, then offset it by the x,y attributes on the <use> element. This is what I'll have to do in SVG-edit, apparently. Regards, Jeff On Wed, Jan 20, 2010 at 6:48 AM, Dirk Schulze <vbs85@gmx.de> wrote: > Hi, > > I don't know the correct behavior of getBbox, but it sound a bit > strange, that the bbox should be the bbox of the rect? The rect isn't > placed at 100,100 on applying the <use> coordinates, but why should it > still have the old coordinates of the rect position? > That would mean, that the bbox is not very helpful on a use element, > since it doesn't have any relation to the real position of it or it's > content? > > Greetings, > Dirk > > Am Dienstag, den 19.01.2010, 21:25 -0600 schrieb Jeff Schiller: >> Is the following test case correct: >> >> <svg xmlns="http://www.w3.org/2000/svg" >> xmlns:xlink="http://www.w3.org/1999/xlink"> >> <rect id="r" x="100" y="100" width="200" height="100" fill="red" /> >> <use id="u" x="200" y="200" width="400" height="200" xlink:href="#r"/> >> >> <script><![CDATA[ >> var u = document.getElementById("u"), >> r = document.getElementById("r"), >> b = u.getBBox(); >> if (console && console.log) console.log([b.x,b.y,b.width,b.height]); >> if (b.x == 200 && b.y == 200 && b.width == 400 && b.height == 200) ) { >> r.setAttribute("fill", "green"); >> } >> ]]></script> >> </svg> >> >> In other words, shouldn't the bbox of a <use> element be defined by >> its x,y,width,height just like a <rect> or an <image> ? No browser >> gives consistent results: >> >> Firefox : 100, 100, 200, 100 >> Opera : 100, 100, 200, 100 >> WebKit : 300, 300, 200, 100 (huh? clearly a bug!) >> >> What's ASV do? >> What's IE9 do? :) >> >> Thanks, >> Jeff > > >
Received on Wednesday, 20 January 2010 17:05:00 UTC