Skip to content

Commit

Permalink
Update expected test results as picosvg now always uses absolute coords
Browse files Browse the repository at this point in the history
  • Loading branch information
anthrotype committed Aug 19, 2020
1 parent e40b78e commit c74d7c9
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion tests/clocks_picosvg.ttx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<SVG>

<svgDoc endGlyphID="3" startGlyphID="2">
<![CDATA[<svg xmlns="http://www.w3.org/2000/svg" version="1.1"><defs><linearGradient x1="64" x2="64" y1="19.751" y2="111.99" gradientUnits="userSpaceOnUse" id="e000::a"><stop stop-color="#ECEFF1" offset=".3212"/><stop stop-color="#B0BEC5" offset="1"/></linearGradient></defs><g id="glyph2" transform="matrix(0.781 0 0 0.781 0 -100)"><path fill="url(#e000::a)" d="M4,64 A60 60 0 1 1 124,64 A60 60 0 1 1 4,64 z" id="glyph2::0"/><path fill="blue" d="m63.8,63.98 h0.4 c2.1,0 3.8,-1.7 3.8,-3.8 v-32.4 c0,-2.1 -1.7,-3.8 -3.8,-3.8 h-0.4 c-2.1,0 -3.8,1.7 -3.8,3.8 v32.4 c0,2.1 1.7,3.8 3.8,3.8 z"/><path fill="green" d="m63.7,63.88 0.34,0.21 c1.79,1.1 4.13,0.55 5.23,-1.24 l11.34,-18.37 c1.1,-1.79 0.55,-4.13 -1.24,-5.23 l-0.34,-0.21 c-1.79,-1.1 -4.13,-0.55 -5.23,1.24 l-11.33,18.37 c-1.1,1.79 -0.55,4.13 1.23,5.23 z"/><path fill="#424242" d="M57,64 A7 7 0 1 1 71,64 A7 7 0 1 1 57,64 z" id="glyph2::3"/><path fill="#fff" d="M61,64 A3 3 0 1 1 67,64 A3 3 0 1 1 61,64 z" id="glyph2::4"/><path fill="#757575" d="M11.89,64.13 A4 4 0 1 1 19.89,64.13 A4 4 0 1 1 11.89,64.13 z" id="glyph2::5"/><use href="#glyph2::5" x="48" y="-48"/><use href="#glyph2::5" x="48" y="48"/><use href="#glyph2::5" x="96"/><path fill="#424242" opacity="0.2" d="M64,8 c30.88,0 56,25.12 56,56 s-25.12,56 -56,56 S8,94.88 8,64 S33.12,8 64,8 M64,4 C30.86,4 4,30.86 4,64 s26.86,60 60,60 s60,-26.86 60,-60 S97.14,4 64,4 L64,4 z" id="glyph2::9"/></g><g id="glyph3" transform="matrix(0.781 0 0 0.781 0 -100)"><use href="#glyph2::0"/><path fill="purple" d="m63.8,63.98 h0.4 c2.1,0 3.8,-1.7 3.8,-3.8 v-32.4 c0,-2.1 -1.7,-3.8 -3.8,-3.8 h-0.4 c-2.1,0 -3.8,1.7 -3.8,3.8 v32.4 c0,2.1 1.7,3.8 3.8,3.8 z"/><path fill="red" d="m63.78,63.81 0.19,0.35 c1.01,1.84 3.32,2.52 5.16,1.51 l18.94,-10.36 c1.84,-1.01 2.52,-3.32 1.51,-5.16 l-0.19,-0.35 c-1.01,-1.84 -3.32,-2.52 -5.16,-1.51 l-18.94,10.36 c-1.84,1.01 -2.52,3.32 -1.51,5.16 z"/><use href="#glyph2::3"/><use href="#glyph2::4"/><use href="#glyph2::5"/><use href="#glyph2::9"/></g></svg>]]>
<![CDATA[<svg xmlns="http://www.w3.org/2000/svg" version="1.1"><defs><linearGradient x1="64" x2="64" y1="19.751" y2="111.99" gradientUnits="userSpaceOnUse" id="e000::a"><stop stop-color="#ECEFF1" offset=".3212"/><stop stop-color="#B0BEC5" offset="1"/></linearGradient></defs><g id="glyph2" transform="matrix(0.781 0 0 0.781 0 -100)"><path fill="url(#e000::a)" d="M4,64 A60 60 0 1 1 124,64 A60 60 0 1 1 4,64 Z" id="glyph2::0"/><path fill="blue" d="M63.8,63.98 H64.2 C66.3,63.98 68,62.28 68,60.18 V27.78 C68,25.68 66.3,23.98 64.2,23.98 H63.8 C61.7,23.98 60,25.68 60,27.78 V60.18 C60,62.28 61.7,63.98 63.8,63.98 Z"/><path fill="green" d="M63.7,63.88 L64.04,64.09 C65.83,65.19 68.17,64.64 69.27,62.85 L80.61,44.48 C81.71,42.69 81.16,40.35 79.37,39.25 L79.03,39.04 C77.24,37.94 74.9,38.49 73.8,40.28 L62.47,58.65 C61.37,60.44 61.92,62.78 63.7,63.88 Z"/><path fill="#424242" d="M57,64 A7 7 0 1 1 71,64 A7 7 0 1 1 57,64 Z" id="glyph2::3"/><path fill="#fff" d="M61,64 A3 3 0 1 1 67,64 A3 3 0 1 1 61,64 Z" id="glyph2::4"/><path fill="#757575" d="M11.89,64.13 A4 4 0 1 1 19.89,64.13 A4 4 0 1 1 11.89,64.13 Z" id="glyph2::5"/><use href="#glyph2::5" x="48" y="-48"/><use href="#glyph2::5" x="48" y="48"/><use href="#glyph2::5" x="96"/><path fill="#424242" opacity="0.2" d="M64,8 C94.88,8 120,33.12 120,64 S94.88,120 64,120 S8,94.88 8,64 S33.12,8 64,8 M64,4 C30.86,4 4,30.86 4,64 S30.86,124 64,124 S124,97.14 124,64 S97.14,4 64,4 L64,4 Z" id="glyph2::9"/></g><g id="glyph3" transform="matrix(0.781 0 0 0.781 0 -100)"><use href="#glyph2::0"/><path fill="purple" d="M63.8,63.98 H64.2 C66.3,63.98 68,62.28 68,60.18 V27.78 C68,25.68 66.3,23.98 64.2,23.98 H63.8 C61.7,23.98 60,25.68 60,27.78 V60.18 C60,62.28 61.7,63.98 63.8,63.98 Z"/><path fill="red" d="M63.78,63.81 L63.97,64.16 C64.98,66 67.29,66.68 69.13,65.67 L88.07,55.31 C89.91,54.3 90.59,51.99 89.58,50.15 L89.39,49.8 C88.38,47.96 86.07,47.28 84.23,48.29 L65.29,58.65 C63.45,59.66 62.77,61.97 63.78,63.81 Z"/><use href="#glyph2::3"/><use href="#glyph2::4"/><use href="#glyph2::5"/><use href="#glyph2::9"/></g></svg>]]>
</svgDoc>
</SVG>

Expand Down
6 changes: 3 additions & 3 deletions tests/clocks_rects_picosvg.ttx
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@
<SVG>

<svgDoc endGlyphID="3" startGlyphID="2">
<![CDATA[<svg xmlns="http://www.w3.org/2000/svg" version="1.1"><defs><linearGradient x1="64" x2="64" y1="19.751" y2="111.99" gradientUnits="userSpaceOnUse" id="e000::a"><stop stop-color="#ECEFF1" offset=".3212"/><stop stop-color="#B0BEC5" offset="1"/></linearGradient></defs><g id="glyph2" transform="matrix(0.781 0 0 0.781 0 -100)"><path fill="url(#e000::a)" d="M4,64 A60 60 0 1 1 124,64 A60 60 0 1 1 4,64 z" id="glyph2::0"/><path fill="blue" d="m63.8,63.98 h0.4 c2.1,0 3.8,-1.7 3.8,-3.8 v-32.4 c0,-2.1 -1.7,-3.8 -3.8,-3.8 h-0.4 c-2.1,0 -3.8,1.7 -3.8,3.8 v32.4 c0,2.1 1.7,3.8 3.8,3.8 z"/><path fill="green" d="m63.7,63.88 0.34,0.21 c1.79,1.1 4.13,0.55 5.23,-1.24 l11.34,-18.37 c1.1,-1.79 0.55,-4.13 -1.24,-5.23 l-0.34,-0.21 c-1.79,-1.1 -4.13,-0.55 -5.23,1.24 l-11.33,18.37 c-1.1,1.79 -0.55,4.13 1.23,5.23 z"/><path fill="#424242" d="M57,64 A7 7 0 1 1 71,64 A7 7 0 1 1 57,64 z" id="glyph2::3"/><path fill="#fff" d="M61,64 A3 3 0 1 1 67,64 A3 3 0 1 1 61,64 z" id="glyph2::4"/><path fill="#757575" d="M11.89,64.13 A4 4 0 1 1 19.89,64.13 A4 4 0 1 1 11.89,64.13 z" id="glyph2::5"/><use href="#glyph2::5" x="48" y="-48"/><use href="#glyph2::5" x="48" y="48"/><use href="#glyph2::5" x="96"/><path fill="#424242" opacity="0.2" d="M64,8 c30.88,0 56,25.12 56,56 s-25.12,56 -56,56 S8,94.88 8,64 S33.12,8 64,8 M64,4 C30.86,4 4,30.86 4,64 s26.86,60 60,60 s60,-26.86 60,-60 S97.14,4 64,4 L64,4 z" id="glyph2::9"/></g><g id="glyph3" transform="matrix(0.781 0 0 0.781 0 -100)"><use href="#glyph2::0"/><path fill="purple" d="m63.8,63.98 h0.4 c2.1,0 3.8,-1.7 3.8,-3.8 v-32.4 c0,-2.1 -1.7,-3.8 -3.8,-3.8 h-0.4 c-2.1,0 -3.8,1.7 -3.8,3.8 v32.4 c0,2.1 1.7,3.8 3.8,3.8 z"/><path fill="red" d="m63.78,63.81 0.19,0.35 c1.01,1.84 3.32,2.52 5.16,1.51 l18.94,-10.36 c1.84,-1.01 2.52,-3.32 1.51,-5.16 l-0.19,-0.35 c-1.01,-1.84 -3.32,-2.52 -5.16,-1.51 l-18.94,10.36 c-1.84,1.01 -2.52,3.32 -1.51,5.16 z"/><use href="#glyph2::3"/><use href="#glyph2::4"/><use href="#glyph2::5"/><use href="#glyph2::9"/></g></svg>]]>
<![CDATA[<svg xmlns="http://www.w3.org/2000/svg" version="1.1"><defs><linearGradient x1="64" x2="64" y1="19.751" y2="111.99" gradientUnits="userSpaceOnUse" id="e000::a"><stop stop-color="#ECEFF1" offset=".3212"/><stop stop-color="#B0BEC5" offset="1"/></linearGradient></defs><g id="glyph2" transform="matrix(0.781 0 0 0.781 0 -100)"><path fill="url(#e000::a)" d="M4,64 A60 60 0 1 1 124,64 A60 60 0 1 1 4,64 Z" id="glyph2::0"/><path fill="blue" d="M63.8,63.98 H64.2 C66.3,63.98 68,62.28 68,60.18 V27.78 C68,25.68 66.3,23.98 64.2,23.98 H63.8 C61.7,23.98 60,25.68 60,27.78 V60.18 C60,62.28 61.7,63.98 63.8,63.98 Z"/><path fill="green" d="M63.7,63.88 L64.04,64.09 C65.83,65.19 68.17,64.64 69.27,62.85 L80.61,44.48 C81.71,42.69 81.16,40.35 79.37,39.25 L79.03,39.04 C77.24,37.94 74.9,38.49 73.8,40.28 L62.47,58.65 C61.37,60.44 61.92,62.78 63.7,63.88 Z"/><path fill="#424242" d="M57,64 A7 7 0 1 1 71,64 A7 7 0 1 1 57,64 Z" id="glyph2::3"/><path fill="#fff" d="M61,64 A3 3 0 1 1 67,64 A3 3 0 1 1 61,64 Z" id="glyph2::4"/><path fill="#757575" d="M11.89,64.13 A4 4 0 1 1 19.89,64.13 A4 4 0 1 1 11.89,64.13 Z" id="glyph2::5"/><use href="#glyph2::5" x="48" y="-48"/><use href="#glyph2::5" x="48" y="48"/><use href="#glyph2::5" x="96"/><path fill="#424242" opacity="0.2" d="M64,8 C94.88,8 120,33.12 120,64 S94.88,120 64,120 S8,94.88 8,64 S33.12,8 64,8 M64,4 C30.86,4 4,30.86 4,64 S30.86,124 64,124 S124,97.14 124,64 S97.14,4 64,4 L64,4 Z" id="glyph2::9"/></g><g id="glyph3" transform="matrix(0.781 0 0 0.781 0 -100)"><use href="#glyph2::0"/><path fill="purple" d="M63.8,63.98 H64.2 C66.3,63.98 68,62.28 68,60.18 V27.78 C68,25.68 66.3,23.98 64.2,23.98 H63.8 C61.7,23.98 60,25.68 60,27.78 V60.18 C60,62.28 61.7,63.98 63.8,63.98 Z"/><path fill="red" d="M63.78,63.81 L63.97,64.16 C64.98,66 67.29,66.68 69.13,65.67 L88.07,55.31 C89.91,54.3 90.59,51.99 89.58,50.15 L89.39,49.8 C88.38,47.96 86.07,47.28 84.23,48.29 L65.29,58.65 C63.45,59.66 62.77,61.97 63.78,63.81 Z"/><use href="#glyph2::3"/><use href="#glyph2::4"/><use href="#glyph2::5"/><use href="#glyph2::9"/></g></svg>]]>
</svgDoc>
<svgDoc endGlyphID="4" startGlyphID="4">
<![CDATA[<svg xmlns="http://www.w3.org/2000/svg" version="1.1"><defs/><g id="glyph4" transform="matrix(10 0 0 10 0 -100)"><path fill="blue" d="M2,2 H8 V4 H2 V2 z"/><path fill="blue" opacity="0.8" d="M4,4 H10 V6 H4 V4 z"/></g></svg>]]>
<![CDATA[<svg xmlns="http://www.w3.org/2000/svg" version="1.1"><defs/><g id="glyph4" transform="matrix(10 0 0 10 0 -100)"><path fill="blue" d="M2,2 H8 V4 H2 V2 Z"/><path fill="blue" opacity="0.8" d="M4,4 H10 V6 H4 V4 Z"/></g></svg>]]>
</svgDoc>
<svgDoc endGlyphID="5" startGlyphID="5">
<![CDATA[<svg xmlns="http://www.w3.org/2000/svg" version="1.1"><defs/><g id="glyph5" transform="matrix(10 0 0 10 0 -100)"><path fill="purple" d="M2,2 H8 V4 H2 V2 z"/><path fill="darkgreen" opacity="0.8" d="M4,4 H10 V6 H4 V4 z"/></g></svg>]]>
<![CDATA[<svg xmlns="http://www.w3.org/2000/svg" version="1.1"><defs/><g id="glyph5" transform="matrix(10 0 0 10 0 -100)"><path fill="purple" d="M2,2 H8 V4 H2 V2 Z"/><path fill="darkgreen" opacity="0.8" d="M4,4 H10 V6 H4 V4 Z"/></g></svg>]]>
</svgDoc>
</SVG>

Expand Down
2 changes: 1 addition & 1 deletion tests/linear_gradient_rect_from_colr_1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/radial_gradient_rect_from_colr_1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions tests/rect_from_colr_0.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions tests/rect_from_colr_1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/rect_picosvg.ttx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<SVG>

<svgDoc endGlyphID="2" startGlyphID="2">
<![CDATA[<svg xmlns="http://www.w3.org/2000/svg" version="1.1"><defs/><g id="glyph2" transform="matrix(10 0 0 10 0 -100)"><path fill="blue" d="M2,2 H8 V4 H2 V2 z"/><path fill="blue" opacity="0.8" d="M4,4 H10 V6 H4 V4 z"/></g></svg>]]>
<![CDATA[<svg xmlns="http://www.w3.org/2000/svg" version="1.1"><defs/><g id="glyph2" transform="matrix(10 0 0 10 0 -100)"><path fill="blue" d="M2,2 H8 V4 H2 V2 Z"/><path fill="blue" opacity="0.8" d="M4,4 H10 V6 H4 V4 Z"/></g></svg>]]>
</svgDoc>
</SVG>

Expand Down
22 changes: 11 additions & 11 deletions tests/svg_path_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def test_addComponent_decompose():
pen.addComponent("a", Affine2D.identity())

assert pen.path.d == (
"M0,0 L0,10 L10,10 L10,0 z "
"M0,15 C0,20 10,20 10,15 z "
"M0,0 L0,10 L10,10 L10,0 Z "
"M0,15 C0,20 10,20 10,15 Z "
"M0,-5 Q0,-8 1.5,-9 Q3,-10 5,-10 Q7,-10 8.5,-9 Q10,-8 10,-5"
)

Expand All @@ -37,22 +37,22 @@ def test_addComponent_decompose_with_transform():
pen.addComponent("a", Affine2D(2, 0, 0, 2, 0, 0))

assert pen.path.d == (
"M0,0 L0,20 L20,20 L20,0 z "
"M0,30 C0,40 20,40 20,30 z "
"M0,0 L0,20 L20,20 L20,0 Z "
"M0,30 C0,40 20,40 20,30 Z "
"M0,-10 Q0,-16 3,-18 Q6,-20 10,-20 Q14,-20 17,-18 Q20,-16 20,-10"
)


def test_draw_onto_existing_path():
path = SVGPath(d="M0,0 L0,10 L10,10 L10,0 z")
path = SVGPath(d="M0,0 L0,10 L10,10 L10,0 Z")
pen = SVGPathPen(path=path)

pen.moveTo((0, 15))
pen.lineTo((5, 20))
pen.lineTo((10, 15))
pen.closePath()

assert path.d == "M0,0 L0,10 L10,10 L10,0 z M0,15 L5,20 L10,15 z"
assert path.d == "M0,0 L0,10 L10,10 L10,0 Z M0,15 L5,20 L10,15 Z"


def test_addComponent_missing():
Expand All @@ -65,12 +65,12 @@ def test_addComponent_missing():
@pytest.mark.parametrize(
"d",
[
"M0,0 L0,10 L10,10 L10,0 z",
"M0,0 L0,10 L10,10 L10,0 Z",
"M0,0 L0,10 L10,10 L10,0",
"M0,0 L0,10 L10,10 L10,0 z M12,0 L12,10 L22,10 L22,0",
"M0,0 L0,10 L10,10 L10,0 M12,0 L12,10 L22,10 L22,0 z",
"M0,0 C0,3 2,5 5,5 C8,5 10,3 10,0 C10,-3 8,-5 5,-5 C2,-5 0,-3 0,0 z",
"M0,0 Q0,10 10,10 Q20,10 20,0 z",
"M0,0 L0,10 L10,10 L10,0 Z M12,0 L12,10 L22,10 L22,0",
"M0,0 L0,10 L10,10 L10,0 M12,0 L12,10 L22,10 L22,0 Z",
"M0,0 C0,3 2,5 5,5 C8,5 10,3 10,0 C10,-3 8,-5 5,-5 C2,-5 0,-3 0,0 Z",
"M0,0 Q0,10 10,10 Q20,10 20,0 Z",
],
)
def test_roundtrip_path_with_pen(d):
Expand Down

0 comments on commit c74d7c9

Please sign in to comment.