<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>29751</bug_id>
          
          <creation_ts>2016-07-22 22:47:52 +0000</creation_ts>
          <short_desc>7.2 equivalent transform of an SVG viewport is mathematically wrong</short_desc>
          <delta_ts>2016-07-23 00:58:23 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>SVG</product>
          <component>Coordinate Systems</component>
          <version>SVG 2.0</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Test Suite</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>ccprog</reporter>
          <assigned_to name="Doug Schepers">schepers</assigned_to>
          <cc>amelia.bellamy.royds</cc>
          
          <qa_contact name="SVG Public List">www-svg</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>127043</commentid>
    <comment_count>0</comment_count>
    <who name="">ccprog</who>
    <bug_when>2016-07-22 22:47:52 +0000</bug_when>
    <thetext>I&apos;ve tried to implement the algorithm described in section &quot;7.2 Computing the equivalent transform of an SVG viewport&quot; and found it to be wrong.

&gt; 9. Initialize translate-x to vb-x - e-x.
&gt; 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 &gt; e-x), the origin needs to be moved to the right: x values get thus smaller (tx &lt; 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

&gt;  9. Initialize translate-x to (e-x - vb-x) * scale-x.
&gt; 10. Initialize translate-y to (e-y - vb-y) * scale-y.

Here are a few test cases to illustrate:

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

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

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

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

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

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

x=&quot;0&quot; y=&quot;0&quot; width=&quot;21&quot; height=&quot;10&quot; viewBox=&quot;11 13 3 2&quot; preserveAspectRatio=&quot;xMinYMin slice&quot; is equivalent to
transform=&quot;translate(-77 -95) scale(7 7)&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127044</commentid>
    <comment_count>1</comment_count>
    <who name="Amelia Bellamy-Royds">amelia.bellamy.royds</who>
    <bug_when>2016-07-22 23:00:41 +0000</bug_when>
    <thetext>We&apos;re now using GitHub issues to track SVG spec bugs, I&apos;ve created a copy of this issue here: https://github.com/w3c/svgwg/issues/215</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127045</commentid>
    <comment_count>2</comment_count>
    <who name="">ccprog</who>
    <bug_when>2016-07-23 00:58:23 +0000</bug_when>
    <thetext>I got directed here from https://www.w3.org/Graphics/SVG/feedback.html, maybe you should update that page.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>