This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 29751 - 7.2 equivalent transform of an SVG viewport is mathematically wrong
Summary: 7.2 equivalent transform of an SVG viewport is mathematically wrong
Status: NEW
Alias: None
Product: SVG
Classification: Unclassified
Component: Coordinate Systems (show other bugs)
Version: SVG 2.0
Hardware: PC Linux
: P2 normal
Target Milestone: Test Suite
Assignee: Doug Schepers
QA Contact: SVG Public List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-22 22:47 UTC by ccprog
Modified: 2016-07-23 00:58 UTC (History)
1 user (show)

See Also:


Attachments

Description ccprog 2016-07-22 22:47:52 UTC
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)"
Comment 1 Amelia Bellamy-Royds 2016-07-22 23:00:41 UTC
We're now using GitHub issues to track SVG spec bugs, I've created a copy of this issue here: https://github.com/w3c/svgwg/issues/215
Comment 2 ccprog 2016-07-23 00:58:23 UTC
I got directed here from https://www.w3.org/Graphics/SVG/feedback.html, maybe you should update that page.