[Bug 29751] New: 7.2 equivalent transform of an SVG viewport is mathematically wrong

https://www.w3.org/Bugs/Public/show_bug.cgi?id=29751

            Bug ID: 29751
           Summary: 7.2 equivalent transform of an SVG viewport is
                    mathematically wrong
           Product: SVG
           Version: SVG 2.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Coordinate Systems
          Assignee: schepers@w3.org
          Reporter: ccprog@gmx.de
        QA Contact: www-svg@w3.org
  Target Milestone: Test Suite

I've tried to implement the algorithm described in section "7.2 Computing the
equivalent transform of an SVG viewport" and found it to be wrong.

> 9. Initialize translate-x to vb-x - e-x.
> 10. Initialize translate-y to vb-y - e-y.

The purpose of this is to move the viewport origin to the left/top coordinates
of the viewBox. I. e. when the viewBox is to the right of the initial origin
(vb-x > e-x), the origin needs to be moved to the right: x values get thus
smaller (tx < 0).

In addition, the last sentence implies that translation is applied after
scaling. In this case the translation values also need to be multiplied by the
scaling values.

Therefore these steps must be

>  9. Initialize translate-x to (e-x - vb-x) * scale-x.
> 10. Initialize translate-y to (e-y - vb-y) * scale-y.

Here are a few test cases to illustrate:

x="0" y="0" width="21" height="10" viewBox="11 13 3 2"
preserveAspectRatio="none" is equivalent to
transform="translate(-77 -65) scale(7 5)"

x="0" y="0" width="21" height="10" viewBox="11 13 3 2"
preserveAspectRatio="xMinYMin meet" is equivalent to
transform="translate(-55 -65) scale(5 5)"

x="0" y="0" width="21" height="10" viewBox="11 13 3 2"
preserveAspectRatio="xMidYMid meet" is equivalent to
transform="translate(-52 -65) scale(5 5)"

x="0" y="0" width="21" height="10" viewBox="11 13 3 2"
preserveAspectRatio="xMaxYMax meet" is equivalent to
transform="translate(-49 -65) scale(5 5)"

x="0" y="0" width="21" height="10" viewBox="11 13 3 2"
preserveAspectRatio="xMinYMin slice" is equivalent to
transform="translate(-77 -91) scale(7 7)"

x="0" y="0" width="21" height="10" viewBox="11 13 3 2"
preserveAspectRatio="xMidYMid slice" is equivalent to
transform="translate(-77 -93) scale(7 7)"

x="0" y="0" width="21" height="10" viewBox="11 13 3 2"
preserveAspectRatio="xMinYMin slice" is equivalent to
transform="translate(-77 -95) scale(7 7)"

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Friday, 22 July 2016 22:47:59 UTC