-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
151 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
setuptools | ||
mediapipe | ||
numpy | ||
isort | ||
black | ||
fastapi | ||
uvicorn | ||
mediapipe | ||
resvg_python | ||
pytest | ||
|
||
# dev deps | ||
setuptools | ||
black | ||
pytest-black | ||
isort | ||
pytest-isort | ||
pytest-snapshot | ||
pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[0.4186729999999983, 47.581327, 0.4186739999999993, 47.581326000000004] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[82.620265, 84.560773, 108.36085444444447, 110.0332] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Model(Path(Arc(start=[ 0.418673 24. ], radius=[23.581327 23.581326], rotation=0.0, large_arc=True, sweep=False, end=[47.581327 24. ]), | ||
Arc(start=[47.581327 24. ], radius=[23.581327 23.581326], rotation=0.0, large_arc=True, sweep=False, end=[ 0.418673 24. ]))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Model(Path(CubicBezier(start=[ 82.839512 110.0332 ], control1=[ 82.839512 110.0332 ], control2=[ 82.585989 109.37437 ], end=[ 82.620265 109.03563 ]), | ||
CubicBezier(start=[ 82.620265 109.03563 ], control1=[ 82.652725 108.7149 ], control2=[ 82.647305 108.55001 ], end=[ 82.828177 108.40751 ]), | ||
CubicBezier(start=[ 82.828177 108.40751 ], control1=[ 83.065614 108.32841 ], control2=[ 82.811777 108.34001 ], end=[ 83.69607 108.50201]), | ||
CubicBezier(start=[ 83.69607 108.50201], control1=[ 83.878214 108.45241 ], control2=[ 84.591743 108.85461 ], end=[ 84.560773 109.04966 ]), | ||
CubicBezier(start=[ 84.560773 109.04966 ], control1=[ 84.554873 109.08666 ], control2=[ 84.502503 109.41525 ], end=[ 84.442116 109.59031 ]), | ||
CubicBezier(start=[ 84.442116 109.59031 ], control1=[ 84.389416 109.7431 ], control2=[ 84.321272 110.04301 ], end=[ 84.231378 110.02965 ]), | ||
CubicBezier(start=[ 84.231378 110.02965 ], control1=[ 83.980786 109.99245 ], control2=[ 83.618946 110.03265 ], end=[ 83.494129 110.01965 ]), | ||
CubicBezier(start=[ 83.494129 110.01965 ], control1=[ 83.115928 109.98135 ], control2=[ 82.839515 110.03295 ], end=[ 82.839515 110.03295 ]), | ||
Line(start=[ 82.839515 110.03295 ], end=[ 82.839512 110.0332 ]))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<ns0:svg xmlns:ns0="http://www.w3.org/2000/svg" version="1.1" viewBox="0,0,1280,720" width="100%"> | ||
<ns0:g transform="translate(616.0, 336.0) scale(1.0)" style="transform-origin: 24px 24px"> | ||
<ns0:defs> | ||
|
||
</ns0:defs> | ||
<ns0:g transform="rotate(0)" style="transform-origin:0px 0px"> | ||
<ns0:g id="face" transform="translate(5, 5)"> | ||
<ns0:path style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.837346;stroke-linejoin:round" d="M 0.4186729999999983,24.0 A 23.581327,23.581326 0.0 1,0 47.581327,24.0 A 23.581327,23.581326 0.0 1,0 0.4186729999999983,24.0" /> | ||
</ns0:g> | ||
</ns0:g> | ||
</ns0:g> | ||
</ns0:svg> |
13 changes: 13 additions & 0 deletions
13
tests/snapshots/test_svg/test_tostring_2/test_tostring_2.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<ns0:svg xmlns:ns0="http://www.w3.org/2000/svg" version="1.1" viewBox="0,0,1280,720" width="100%"> | ||
<ns0:g transform="translate(556.409481, 250.8029727777778) scale(1.0)" style="transform-origin: 84px 109px"> | ||
<ns0:defs> | ||
<ns0:clipPath id="left-eye-clippath"> | ||
<ns0:use href="#left-eye" /> | ||
</ns0:clipPath> | ||
<ns0:clipPath id="left"> | ||
<ns0:use href="#left-2" /> | ||
</ns0:clipPath> | ||
</ns0:defs> | ||
<ns0:path id="left-eye" style="opacity:1;fill:#ffffff;fill-opacity:0.5;fill-rule:evenodd;stroke:#000000;stroke-width:0.132292;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:normal" d="M 82.839512,110.0332 C 82.839512,110.0332 82.585989,109.37437 82.620265,109.03563 C 82.652725,108.7149 82.647305,108.55001 82.828177,108.40751 C 83.065614,108.32841 82.81177699999999,108.34001 83.69606999999999,108.50201 C 83.87821399999999,108.45241 84.591743,108.85461 84.560773,109.04966 C 84.554873,109.08666000000001 84.502503,109.41525 84.442116,109.59031 C 84.389416,109.7431 84.321272,110.04301 84.23137799999999,110.02965 C 83.980786,109.99245 83.618946,110.03265 83.49412899999999,110.01965 C 83.11592799999998,109.98134999999999 82.83951499999999,110.03295 82.83951499999999,110.03295 L 82.839512,110.0332" /> | ||
</ns0:g> | ||
</ns0:svg> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import xml.etree.ElementTree as ET | ||
from xml.dom import minidom | ||
|
||
from src.svg.model import Model | ||
|
||
xml_ellipse_string = """<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<svg> | ||
<g id="face" transform="translate(5, 5)"> | ||
<ellipse | ||
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.837346;stroke-linejoin:round" | ||
cx="24" | ||
cy="24" | ||
rx="23.581327" | ||
ry="23.581326" /> | ||
</g> | ||
</svg> | ||
""" | ||
|
||
xml_curve_string = """<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<svg xmlns:rein="https://github.com/ker0olos/rein"> | ||
<defs> | ||
<clipPath id="left"> | ||
<use href="#left-2"/> | ||
</clipPath> | ||
</defs> | ||
<path | ||
rein:scale="0.085" | ||
rein:clippath="on" | ||
id="left-eye" | ||
d="m 82.839512,110.0332 c 0,0 -0.253523,-0.65883 -0.219247,-0.99757 0.03246,-0.32073 0.02704,-0.48562 0.207912,-0.62812 0.237437,-0.0791 -0.0164,-0.0675 0.867893,0.0945 0.182144,-0.0496 0.895673,0.3526 0.864703,0.54765 -0.0059,0.037 -0.05827,0.36559 -0.118657,0.54065 -0.0527,0.15279 -0.120844,0.4527 -0.210738,0.43934 -0.250592,-0.0372 -0.612432,0.003 -0.737249,-0.01 -0.378201,-0.0383 -0.654614,0.0133 -0.654614,0.0133 z" | ||
style="opacity:1;fill:#ffffff;fill-opacity:0.5;fill-rule:evenodd;stroke:#000000;stroke-width:0.132292;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:normal" /> | ||
</svg> | ||
""" | ||
|
||
|
||
xml_inkscape_string = """<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<svg xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"> | ||
<g inkscape:label="Layer 1" id="layer1"> | ||
<ellipse | ||
id="path-7874922389283097748029598590584979208590" | ||
inkscape:label="Elliope" | ||
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.837346;stroke-linejoin:round" | ||
cx="24" | ||
cy="24" | ||
rx="23.581327" | ||
ry="23.581326" /> | ||
</g> | ||
</svg> | ||
""" | ||
|
||
|
||
def test_parsing(snapshot): | ||
model = Model(xml_ellipse_string) | ||
|
||
snapshot.assert_match(str(model), "test_parsing.xml") | ||
|
||
|
||
def test_parsing_2(snapshot): | ||
model = Model(xml_curve_string) | ||
|
||
snapshot.assert_match(str(model), "test_parsing_2.xml") | ||
|
||
|
||
def test_bbox(snapshot): | ||
model = Model(xml_ellipse_string) | ||
|
||
snapshot.assert_match(str(model.bbox), "test_bbox.xml") | ||
|
||
|
||
def test_bbox_2(snapshot): | ||
model = Model(xml_curve_string) | ||
|
||
snapshot.assert_match(str(model.bbox), "test_bbox_2.xml") | ||
|
||
|
||
def test_inkscape_labels(): | ||
model = Model(xml_inkscape_string) | ||
|
||
element = minidom.parseString(model.tostring()) | ||
|
||
assert element.getElementsByTagName("g")[1].attributes["id"].value == "Layer 1" | ||
assert element.getElementsByTagName("path")[0].attributes["id"].value == "Elliope" | ||
|
||
|
||
def test_tostring(snapshot): | ||
model = Model(xml_ellipse_string) | ||
|
||
element = ET.XML(model.tostring()) | ||
|
||
ET.indent(element) | ||
|
||
snapshot.assert_match(ET.tostring(element, encoding="unicode"), "test_tostring.xml") | ||
|
||
|
||
def test_tostring_2(snapshot): | ||
model = Model(xml_curve_string) | ||
|
||
element = ET.XML(model.tostring()) | ||
|
||
ET.indent(element) | ||
|
||
snapshot.assert_match( | ||
ET.tostring(element, encoding="unicode"), "test_tostring_2.xml" | ||
) |