scour.py: Modify optimizeTransform to remove superfluous []s and ()s.

testscour.py: Add unit tests for Johan Sundström's fix for bug 722544, "SVG transform matrix() arg order is a1 b1 a2 b2 a3 b3, not a1 a2 a3 b1 b2 b3".

unittests/: Edit the unit tests' support files not to have a second line with the correct transformation. This is customarily in testscour.py.
This commit is contained in:
Louis Simard 2011-02-21 20:51:35 -05:00
parent 338e56f1b1
commit ba3371e282
15 changed files with 102 additions and 29 deletions

View file

@ -1,4 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 9 9">
<line stroke="rgba(255,0,0,0.5)" y1="9" x1="9" transform="matrix(1 0 0 1 0 0)"/>
<line stroke="rgba(0,0,255,0.5)" y1="9" x1="9"/>
</svg>

Before

Width:  |  Height:  |  Size: 212 B

After

Width:  |  Height:  |  Size: 162 B

Before After
Before After

View file

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="-9 0 9 9">
<line stroke="rgba(255,0,0,0.5)" y1="9" x1="9" transform="matrix(-0.70710678118654746 0.70710678118654757 -0.70710678118654757 -0.70710678118654746 0 0)"/>
<line stroke="rgba(0,0,255,0.5)" y1="9" x1="9" transform="rotate(135)"/>
</svg>

Before

Width:  |  Height:  |  Size: 367 B

After

Width:  |  Height:  |  Size: 293 B

Before After
Before After

View file

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="-9 0 9 9">
<line stroke="rgba(255,0,0,0.5)" y1="9" x1="9" transform="matrix(0.70710678118654757 0.70710678118654746 -0.70710678118654746 0.70710678118654757 0 0)"/>
<line stroke="rgba(0,0,255,0.5)" y1="9" x1="9" transform="rotate(45)"/>
</svg>

Before

Width:  |  Height:  |  Size: 364 B

After

Width:  |  Height:  |  Size: 291 B

Before After
Before After

View file

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="-9 0 9 9">
<line stroke="rgba(255,0,0,0.5)" y1="9" x1="9" transform="matrix(0 1 -1 0 0 0)"/>
<line stroke="rgba(0,0,255,0.5)" y1="9" x1="9" transform="rotate(90)"/>
</svg>

Before

Width:  |  Height:  |  Size: 292 B

After

Width:  |  Height:  |  Size: 219 B

Before After
Before After

View file

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="-9 0 9 9">
<line stroke="rgba(255,0,0,0.5)" y1="9" x1="9" transform="matrix(-0.70710678118654746 -0.70710678118654757 0.70710678118654757 -0.70710678118654746 0 0)"/>
<line stroke="rgba(0,0,255,0.5)" y1="9" x1="9" transform="rotate(-135)"/>
</svg>

Before

Width:  |  Height:  |  Size: 368 B

After

Width:  |  Height:  |  Size: 293 B

Before After
Before After

View file

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="-9 0 9 9">
<line stroke="rgba(255,0,0,0.5)" y1="9" x1="9" transform="matrix(0.70710678118654757 -0.70710678118654746 0.70710678118654746 0.70710678118654757 0 0)"/>
<line stroke="rgba(0,0,255,0.5)" y1="9" x1="9" transform="rotate(-45)"/>
</svg>

Before

Width:  |  Height:  |  Size: 365 B

After

Width:  |  Height:  |  Size: 291 B

Before After
Before After

View file

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="-9 0 9 9">
<line stroke="rgba(255,0,0,0.5)" y1="9" x1="9" transform="matrix(0 -1 1 0 0 0)"/>
<line stroke="rgba(0,0,255,0.5)" y1="9" x1="9" transform="rotate(-90)"/>
</svg>

Before

Width:  |  Height:  |  Size: 293 B

After

Width:  |  Height:  |  Size: 219 B

Before After
Before After

View file

@ -1,4 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 18 27">
<line stroke="rgba(255,0,0,0.5)" y1="9" x1="9" transform="matrix(2 0 0 3 0 0)"/>
<line stroke="rgba(0,0,255,0.5)" y1="9" x1="9" transform="scale(2 3)"/>
</svg>

Before

Width:  |  Height:  |  Size: 237 B

After

Width:  |  Height:  |  Size: 164 B

Before After
Before After

View file

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="-9 -9 9 9">
<line stroke="rgba(255,0,0,0.5)" y1="9" x1="9" transform="matrix(-1 0 0 -1 0 0)"/>
<line stroke="rgba(0,0,255,0.5)" y1="9" x1="9" transform="scale(-1)"/>
</svg>

Before

Width:  |  Height:  |  Size: 293 B

After

Width:  |  Height:  |  Size: 221 B

Before After
Before After

View file

@ -1,4 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="2 3 9 9">
<line stroke="rgba(255,0,0,0.5)" y1="9" x1="9" transform="matrix(1 0 0 1 2 3)"/>
<line stroke="rgba(0,0,255,0.5)" y1="9" x1="9" transform="translate(2 3)"/>
</svg>

Before

Width:  |  Height:  |  Size: 239 B

After

Width:  |  Height:  |  Size: 162 B

Before After
Before After

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="-9 0 9 9">
<line stroke="rgba(255,0,0,0.5)" y1="9" x1="9" transform="rotate(90 0 0.0)"/>
<line stroke="rgba(0,0,255,0.5)" y1="9" x1="9" transform="rotate(90)"/>
<!-- optional zero trailing args to transform type rotate get removed -->
</svg>

Before

Width:  |  Height:  |  Size: 364 B

After

Width:  |  Height:  |  Size: 291 B

Before After
Before After

View file

@ -1,5 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 9 9">
<line stroke="rgba(255,0,0,0.5)" y1="9" x1="9" transform="skewX(0)"/>
<line stroke="rgba(0,0,255,0.5)" y1="9" x1="9"/>
<!-- skewX(0) is the identity transform, which can safely be removed -->
</svg>

Before

Width:  |  Height:  |  Size: 276 B

After

Width:  |  Height:  |  Size: 226 B

Before After
Before After

View file

@ -1,5 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 9 9">
<line stroke="rgba(255,0,0,0.5)" y1="9" x1="9" transform="skewY(0)"/>
<line stroke="rgba(0,0,255,0.5)" y1="9" x1="9"/>
<!-- skewY(0) is the identity transform, which can safely be removed -->
</svg>

Before

Width:  |  Height:  |  Size: 276 B

After

Width:  |  Height:  |  Size: 226 B

Before After
Before After