Closed Bug 233925 Opened 21 years ago Closed 20 years ago

Percentage units should be relative to viewBox not viewport

Categories

(Core :: SVG, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: alex, Assigned: alex)

References

()

Details

See http://www.croczilla.com/~alex/conformance_suite/svg/coords-units-02-b.svg.
We're failing on the percentage units tests.
FIXED? That URL is the same test as:
http://www.croczilla.com/~alex/fosdem2003/w3c-conformance-suite/coords-unitsProc-BE-04-ps.html

It looks bad linking directly to the svg because it should be constrained to a
480x360 (or same ratio) viewport. 
I think the latter test is an old version. 
I don't find the specs particularly clear on this, but I'm pretty sure
percentages should be based on the viewport element's user coordinate system,
not the viewport itself.
See also this example:
http://www.croczilla.com/~alex/reference/SVG/REC-SVG11-20030114/images/coords/Units.svg
and the reference image:
http://www.croczilla.com/~alex/reference/SVG/REC-SVG11-20030114/images/coords/Units.png
We fail the percentage tests in the right column. (We also fail the em-unit
tests in the middle column, but that's a separate issue).
The spec say about this test:
(http://www.croczilla.com/~alex/reference/SVG/REC-SVG11-20030114/coords.html)
The three rectangles on the right demonstrate the use of percentages. Note that
the width and height of the viewport in the user coordinate system for the
viewport element (in this case, the outermost 'svg' element) are 4000 and 2000,
respectively, because processing the viewBox attribute results in a transformed
user coordinate system. The topmost rectangle, which is specified in percentage
units, is exactly the same size as the middle rectangle, which is specified in
equivalent user units. In particular, note that the 'stroke-width' property in
the middle rectangle is set to 1% of the sqrt((actual-width)**2 +
(actual-height)**2)) / sqrt(2), which in this case is
.01*sqrt(4000*4000+2000*2000)/sqrt(2), or 31.62. The bottom rectangle of the
group illustrates what happens when values specified in percentage units are scaled.
Actually the specs are quite clear:
http://www.croczilla.com/~alex/reference/SVG/REC-SVG11-20030114/coords.html#Units:
For percentage values that are defined to be relative to the size of viewport:

    * For any x-coordinate value or width value expressed as a percentage of the
viewport, the value to use is the specified percentage of the actual-width in
user units for the nearest containing viewport, where actual-width is the width
dimension of the viewport element WITHIN THE USER COORDINATE SYSTEM for the
viewport element.
Depends on: 252637
Fixed by bug#252637 checkin
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.