1
1
mirror of https://github.com/exyte/Macaw.git synced 2024-09-21 09:59:10 +03:00

Merge pull request #373 from f3dm76/task/miterLimit

Fix #348: Attribute stroke-miterlimit is ignored
This commit is contained in:
Yuri Strot 2018-05-25 15:28:24 +07:00 committed by GitHub
commit 7a094c0824
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 1886 additions and 689 deletions

File diff suppressed because it is too large Load Diff

View File

@ -12,6 +12,11 @@ class MacawSVGTests: XCTestCase {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testCreate() {
createJSON("painting-stroke-07-t-manual")
createJSON("shapes-polyline-02-t-manual")
}
func validate(node: Node, referenceFile: String) {
let bundle = Bundle(for: type(of: TestUtils()))
@ -249,6 +254,11 @@ class MacawSVGTests: XCTestCase {
validateJSON("painting-stroke-02-t-manual")
}
func testPaintingStroke07() {
validateJSON("painting-stroke-07-t-manual")
}
func testPathsData01() {
validateJSON("paths-data-01-t-manual")
}
@ -297,6 +307,10 @@ class MacawSVGTests: XCTestCase {
validateJSON("shapes-polyline-01-t-manual")
}
func testShapesPolyline02() {
validateJSON("shapes-polyline-02-t-manual")
}
func testShapesPolygon02() {
validateJSON("shapes-polygon-02-t-manual")
}

View File

@ -166,7 +166,7 @@ Status of each test:
|[painting-stroke-04-t-manual](w3cSVGTests/painting-stroke-04-t-manual.svg) | ✅ |
|[painting-stroke-05-t-manual](w3cSVGTests/painting-stroke-05-t-manual.svg) | ✅ |
|[painting-stroke-06-t-manual](w3cSVGTests/painting-stroke-06-t-manual.svg) | ✅ |
|[painting-stroke-07-t-manual](w3cSVGTests/painting-stroke-07-t-manual.svg) | [#348](https://github.com/exyte/Macaw/issues/348) |
|[painting-stroke-07-t-manual](w3cSVGTests/painting-stroke-07-t-manual.svg) | |
|[painting-stroke-08-t-manual](w3cSVGTests/painting-stroke-08-t-manual.svg) | ✅ |
|[painting-stroke-09-t-manual](w3cSVGTests/painting-stroke-09-t-manual.svg) | ✅ |
|[painting-stroke-10-t-manual](w3cSVGTests/painting-stroke-10-t-manual.svg) | ❌ |
@ -241,7 +241,7 @@ Status of each test:
|[shapes-polygon-02-t-manual](w3cSVGTests/shapes-polygon-02-t-manual.svg) | ✅ |
|[shapes-polygon-03-t-manual](w3cSVGTests/shapes-polygon-03-t-manual.svg) | ✅ |
|[shapes-polyline-01-t-manual](w3cSVGTests/shapes-polyline-01-t-manual.svg) | ✅ |
|[shapes-polyline-02-t-manual](w3cSVGTests/shapes-polyline-02-t-manual.svg) | |
|[shapes-polyline-02-t-manual](w3cSVGTests/shapes-polyline-02-t-manual.svg) | |
|[shapes-rect-02-t-manual](w3cSVGTests/shapes-rect-02-t-manual.svg) | ❌[ios bug](https://stackoverflow.com/q/18880919)|
|[shapes-rect-03-t-manual](w3cSVGTests/shapes-rect-03-t-manual.svg) | ❌[ios bug](https://stackoverflow.com/q/18880919)|
|[shapes-rect-04-f-manual](w3cSVGTests/shapes-rect-04-f-manual.svg) | ✅ |

View File

@ -0,0 +1,321 @@
{
"layout" : {
"yAligningMode" : "mid",
"scalingMode" : "meet",
"svgSize" : {
"height" : "100.0%",
"width" : "100.0%"
},
"xAligningMode" : "mid",
"viewBox" : {
"x" : 0,
"w" : 480,
"type" : "Rect",
"y" : 0,
"h" : 360
}
},
"contents" : [
{
"contents" : [
{
"place" : "1.2, 0, 0, 1.2, 72, 36",
"contents" : [
{
"stroke" : {
"join" : "miter",
"cap" : "butt",
"fill" : {
"type" : "Color",
"val" : 0
},
"dashes" : [
],
"width" : 10
},
"form" : {
"type" : "Path",
"segments" : [
{
"type" : "M",
"data" : [
20,
20
]
},
{
"type" : "L",
"data" : [
200,
30
]
},
{
"type" : "L",
"data" : [
20,
40
]
}
]
},
"node" : "Shape"
},
{
"stroke" : {
"join" : "miter",
"cap" : "butt",
"fill" : {
"type" : "Color",
"val" : 0
},
"dashes" : [
],
"width" : 10
},
"form" : {
"type" : "Path",
"segments" : [
{
"type" : "M",
"data" : [
20,
50
]
},
{
"type" : "L",
"data" : [
200,
60
]
},
{
"type" : "L",
"data" : [
20,
70
]
}
]
},
"node" : "Shape"
},
{
"stroke" : {
"join" : "miter",
"cap" : "butt",
"fill" : {
"type" : "Color",
"val" : 0
},
"dashes" : [
],
"width" : 10
},
"form" : {
"type" : "Path",
"segments" : [
{
"type" : "M",
"data" : [
20,
80
]
},
{
"type" : "L",
"data" : [
200,
90
]
},
{
"type" : "L",
"data" : [
20,
100
]
}
]
},
"node" : "Shape"
},
{
"stroke" : {
"join" : "miter",
"cap" : "butt",
"fill" : {
"type" : "Color",
"val" : 0
},
"dashes" : [
],
"width" : 10
},
"form" : {
"type" : "Path",
"segments" : [
{
"type" : "M",
"data" : [
20,
110
]
},
{
"type" : "L",
"data" : [
200,
120
]
},
{
"type" : "L",
"data" : [
20,
130
]
}
]
},
"node" : "Shape"
},
{
"stroke" : {
"join" : "miter",
"cap" : "butt",
"fill" : {
"type" : "Color",
"val" : 0
},
"dashes" : [
],
"width" : 10
},
"form" : {
"type" : "Path",
"segments" : [
{
"type" : "M",
"data" : [
20,
140
]
},
{
"type" : "L",
"data" : [
200,
150
]
},
{
"type" : "L",
"data" : [
20,
160
]
}
]
},
"node" : "Shape"
},
{
"stroke" : {
"join" : "miter",
"cap" : "butt",
"fill" : {
"type" : "Color",
"val" : 0
},
"dashes" : [
],
"width" : 10
},
"form" : {
"type" : "Path",
"segments" : [
{
"type" : "M",
"data" : [
20,
170
]
},
{
"type" : "L",
"data" : [
200,
180
]
},
{
"type" : "L",
"data" : [
20,
190
]
}
]
},
"node" : "Shape"
}
],
"node" : "Group"
}
],
"node" : "Group"
},
{
"contents" : [
{
"baseline" : "bottom",
"fill" : {
"type" : "Color",
"val" : 0
},
"node" : "Text",
"align" : "min",
"text" : "$Revision: 1.7 $",
"place" : "1, 0, 0, 1, 10, 340",
"font" : {
"name" : "SVGFreeSansASCII,sans-serif",
"size" : 32,
"weight" : "normal"
}
}
],
"node" : "Group"
},
{
"stroke" : {
"join" : "miter",
"cap" : "butt",
"fill" : {
"type" : "Color",
"val" : 0
},
"dashes" : [
],
"width" : 1
},
"form" : {
"x" : 1,
"w" : 478,
"type" : "Rect",
"y" : 1,
"h" : 358
},
"node" : "Shape"
}
],
"node" : "Canvas"
}

View File

@ -0,0 +1,63 @@
<svg version="1.1" baseProfile="tiny" id="svg-root"
width="100%" height="100%" viewBox="0 0 480 360"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!--======================================================================-->
<!--= SVG 1.1 2nd Edition Test Case =-->
<!--======================================================================-->
<!--= Copyright 2009 World Wide Web Consortium, (Massachusetts =-->
<!--= Institute of Technology, European Research Consortium for =-->
<!--= Informatics and Mathematics (ERCIM), Keio University). =-->
<!--= All Rights Reserved. =-->
<!--= See http://www.w3.org/Consortium/Legal/. =-->
<!--======================================================================-->
<d:SVGTestCase xmlns:d="http://www.w3.org/2000/02/svg/testsuite/description/"
template-version="1.4" reviewer="CL" author="CN" status="accepted"
version="$Revision: 1.7 $" testname="$RCSfile: painting-stroke-07-t.svg,v $">
<d:testDescription xmlns="http://www.w3.org/1999/xhtml" href="http://www.w3.org/TR/SVG11/painting.html#StrokeProperties">
<p>
Test effect of different stroke-miterlimits. For this particular combination of
stroke width and angle, the cut off value of stroke-miterlimit is 18.028.
</p>
</d:testDescription>
<d:operatorScript xmlns="http://www.w3.org/1999/xhtml">
<p>
Run the test. No interaction required.
</p>
</d:operatorScript>
<d:passCriteria xmlns="http://www.w3.org/1999/xhtml">
<p>
The first and second subtests should not truncate the stroke, and all the rest must truncate it.
</p>
</d:passCriteria>
</d:SVGTestCase>
<title id="test-title">$RCSfile: painting-stroke-07-t.svg,v $</title>
<defs>
<font-face font-family="SVGFreeSansASCII" unicode-range="U+0-7F">
<font-face-src>
<font-face-uri xlink:href="../resources/SVGFreeSans.svg#ascii"/>
</font-face-src>
</font-face>
</defs>
<g id="test-body-content" font-family="SVGFreeSansASCII,sans-serif" font-size="18">
<g transform="scale(1.2) translate(60, 30)">
<!-- test different miterlimits -->
<path stroke="black" stroke-width="10" stroke-linejoin="miter" stroke-miterlimit="20" fill="none" d="M 20 20 L 200 30 L 20 40"/>
<path stroke="black" stroke-width="10" stroke-linejoin="miter" stroke-miterlimit="18.1" fill="none" d="M 20 50 L 200 60 L 20 70"/>
<path stroke="black" stroke-width="10" stroke-linejoin="miter" stroke-miterlimit="17.9" fill="none" d="M 20 80 L 200 90 L 20 100"/>
<path stroke="black" stroke-width="10" stroke-linejoin="miter" stroke-miterlimit="17" fill="none" d="M 20 110 L 200 120 L 20 130"/>
<path stroke="black" stroke-width="10" stroke-linejoin="miter" stroke-miterlimit="4" fill="none" d="M 20 140 L 200 150 L 20 160"/>
<path stroke="black" stroke-width="10" stroke-linejoin="miter" stroke-miterlimit="1" fill="none" d="M 20 170 L 200 180 L 20 190"/>
</g>
</g>
<g font-family="SVGFreeSansASCII,sans-serif" font-size="32">
<text id="revision" x="10" y="340" stroke="none" fill="black">$Revision: 1.7 $</text>
</g>
<rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000000"/>
<!-- comment out this watermark once the test is approved -->
<!--<g id="draft-watermark">
<rect x="1" y="1" width="478" height="20" fill="red" stroke="black" stroke-width="1"/>
<text font-family="SVGFreeSansASCII,sans-serif" font-weight="bold" font-size="20" x="240"
text-anchor="middle" y="18" stroke-width="0.5" stroke="black" fill="white">DRAFT</text>
</g>-->
</svg>

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -0,0 +1,691 @@
{
"layout" : {
"yAligningMode" : "mid",
"scalingMode" : "meet",
"svgSize" : {
"height" : "100.0%",
"width" : "100.0%"
},
"xAligningMode" : "mid",
"viewBox" : {
"x" : 0,
"w" : 480,
"type" : "Rect",
"y" : 0,
"h" : 360
}
},
"contents" : [
{
"contents" : [
{
"contents" : [
{
"stroke" : {
"join" : "miter",
"cap" : "butt",
"fill" : {
"type" : "Color",
"val" : 30464
},
"dashes" : [
],
"width" : 8
},
"form" : {
"type" : "Polyline",
"points" : [
10,
50,
35,
150,
60,
50,
85,
150,
110,
50,
135,
150
]
},
"node" : "Shape"
},
{
"stroke" : {
"join" : "miter",
"cap" : "butt",
"fill" : {
"type" : "Color",
"val" : 30464
},
"dashes" : [
],
"width" : 8
},
"form" : {
"type" : "Polyline",
"points" : [
220,
50,
267,
84,
249,
140,
190,
140,
172,
84,
220,
50
]
},
"node" : "Shape"
},
{
"fill" : {
"type" : "Color",
"val" : 3381606
},
"form" : {
"type" : "Polyline",
"points" : [
310,
50,
335,
150,
360,
50,
385,
150,
410,
50,
435,
150
]
},
"node" : "Shape",
"stroke" : {
"join" : "miter",
"cap" : "butt",
"fill" : {
"type" : "Color",
"val" : 30464
},
"dashes" : [
],
"width" : 8
}
},
{
"stroke" : {
"join" : "miter",
"cap" : "butt",
"fill" : {
"type" : "Color",
"val" : 30464
},
"dashes" : [
],
"width" : 8
},
"form" : {
"type" : "Polyline",
"points" : [
59,
185,
98,
203,
108,
245,
82,
279,
39,
280,
11,
247,
19,
205
]
},
"node" : "Shape"
},
{
"fill" : {
"type" : "Color",
"val" : 3381606
},
"form" : {
"type" : "Polyline",
"points" : [
189,
185,
228,
203,
238,
245,
212,
279,
169,
280,
141,
247,
149,
205
]
},
"node" : "Shape",
"stroke" : {
"join" : "miter",
"cap" : "butt",
"fill" : {
"type" : "Color",
"val" : 30464
},
"dashes" : [
],
"width" : 8
}
},
{
"fill" : {
"type" : "Color",
"val" : 3381606
},
"form" : {
"type" : "Polyline",
"points" : [
270,
225,
300,
245,
320,
225,
340,
245,
280,
280,
390,
280,
420,
240,
280,
185
]
},
"node" : "Shape",
"stroke" : {
"join" : "miter",
"cap" : "butt",
"fill" : {
"type" : "Color",
"val" : 30464
},
"dashes" : [
],
"width" : 8
}
}
],
"node" : "Group"
},
{
"contents" : [
{
"stroke" : {
"join" : "bevel",
"cap" : "butt",
"fill" : {
"type" : "Color",
"val" : 3394662
},
"dashes" : [
],
"width" : 3
},
"form" : {
"type" : "Path",
"segments" : [
{
"type" : "M",
"data" : [
10,
50
]
},
{
"type" : "L",
"data" : [
35,
150
]
},
{
"type" : "L",
"data" : [
60,
50
]
},
{
"type" : "L",
"data" : [
85,
150
]
},
{
"type" : "L",
"data" : [
110,
50
]
},
{
"type" : "L",
"data" : [
135,
150
]
}
]
},
"node" : "Shape"
},
{
"stroke" : {
"join" : "bevel",
"cap" : "butt",
"fill" : {
"type" : "Color",
"val" : 3394662
},
"dashes" : [
],
"width" : 3
},
"form" : {
"type" : "Path",
"segments" : [
{
"type" : "M",
"data" : [
220,
50
]
},
{
"type" : "L",
"data" : [
267,
84
]
},
{
"type" : "L",
"data" : [
249,
140
]
},
{
"type" : "L",
"data" : [
190,
140
]
},
{
"type" : "L",
"data" : [
172,
84
]
},
{
"type" : "L",
"data" : [
220,
50
]
}
]
},
"node" : "Shape"
},
{
"stroke" : {
"join" : "bevel",
"cap" : "butt",
"fill" : {
"type" : "Color",
"val" : 3394662
},
"dashes" : [
],
"width" : 3
},
"form" : {
"type" : "Path",
"segments" : [
{
"type" : "M",
"data" : [
310,
50
]
},
{
"type" : "L",
"data" : [
335,
150
]
},
{
"type" : "L",
"data" : [
360,
50
]
},
{
"type" : "L",
"data" : [
385,
150
]
},
{
"type" : "L",
"data" : [
410,
50
]
},
{
"type" : "L",
"data" : [
435,
150
]
}
]
},
"node" : "Shape"
},
{
"stroke" : {
"join" : "bevel",
"cap" : "butt",
"fill" : {
"type" : "Color",
"val" : 3394662
},
"dashes" : [
],
"width" : 3
},
"form" : {
"type" : "Path",
"segments" : [
{
"type" : "M",
"data" : [
59,
185
]
},
{
"type" : "L",
"data" : [
98,
203
]
},
{
"type" : "L",
"data" : [
108,
245
]
},
{
"type" : "L",
"data" : [
82,
279
]
},
{
"type" : "L",
"data" : [
39,
280
]
},
{
"type" : "L",
"data" : [
11,
247
]
},
{
"type" : "L",
"data" : [
19,
205
]
}
]
},
"node" : "Shape"
},
{
"stroke" : {
"join" : "bevel",
"cap" : "butt",
"fill" : {
"type" : "Color",
"val" : 3394662
},
"dashes" : [
],
"width" : 3
},
"form" : {
"type" : "Path",
"segments" : [
{
"type" : "M",
"data" : [
189,
185
]
},
{
"type" : "L",
"data" : [
228,
203
]
},
{
"type" : "L",
"data" : [
238,
245
]
},
{
"type" : "L",
"data" : [
212,
279
]
},
{
"type" : "L",
"data" : [
169,
280
]
},
{
"type" : "L",
"data" : [
141,
247
]
},
{
"type" : "L",
"data" : [
149,
205
]
}
]
},
"node" : "Shape"
},
{
"stroke" : {
"join" : "bevel",
"cap" : "butt",
"fill" : {
"type" : "Color",
"val" : 3394662
},
"dashes" : [
],
"width" : 3
},
"form" : {
"type" : "Path",
"segments" : [
{
"type" : "M",
"data" : [
270,
225
]
},
{
"type" : "L",
"data" : [
300,
245
]
},
{
"type" : "L",
"data" : [
320,
225
]
},
{
"type" : "L",
"data" : [
340,
245
]
},
{
"type" : "L",
"data" : [
280,
280
]
},
{
"type" : "L",
"data" : [
390,
280
]
},
{
"type" : "L",
"data" : [
420,
240
]
},
{
"type" : "L",
"data" : [
280,
185
]
}
]
},
"node" : "Shape"
}
],
"node" : "Group"
}
],
"node" : "Group"
},
{
"contents" : [
{
"baseline" : "bottom",
"fill" : {
"type" : "Color",
"val" : 0
},
"node" : "Text",
"align" : "min",
"text" : "$Revision: 1.3 $",
"place" : "1, 0, 0, 1, 10, 340",
"font" : {
"name" : "SVGFreeSansASCII,sans-serif",
"size" : 32,
"weight" : "normal"
}
}
],
"node" : "Group"
},
{
"stroke" : {
"join" : "miter",
"cap" : "butt",
"fill" : {
"type" : "Color",
"val" : 0
},
"dashes" : [
],
"width" : 1
},
"form" : {
"x" : 1,
"w" : 478,
"type" : "Rect",
"y" : 1,
"h" : 358
},
"node" : "Shape"
}
],
"node" : "Canvas"
}

View File

@ -0,0 +1,81 @@
<svg version="1.1" baseProfile="tiny" id="svg-root"
width="100%" height="100%" viewBox="0 0 480 360"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!--======================================================================-->
<!--= SVG 1.1 2nd Edition Test Case =-->
<!--======================================================================-->
<!--= Copyright 2009 World Wide Web Consortium, (Massachusetts =-->
<!--= Institute of Technology, European Research Consortium for =-->
<!--= Informatics and Mathematics (ERCIM), Keio University). =-->
<!--= All Rights Reserved. =-->
<!--= See http://www.w3.org/Consortium/Legal/. =-->
<!--======================================================================-->
<d:SVGTestCase xmlns:d="http://www.w3.org/2000/02/svg/testsuite/description/"
template-version="1.4" reviewer="AG" author=" CL" status="accepted"
version="$Revision: 1.3 $" testname="$RCSfile: shapes-polyline-02-t.svg,v $">
<d:testDescription xmlns="http://www.w3.org/1999/xhtml" href="http://www.w3.org/TR/SVG11/shapes.html#PolylineElement">
<p>
Checks that polylines and the equivalent paths are indeed equivalent.
</p>
</d:testDescription>
<d:operatorScript xmlns="http://www.w3.org/1999/xhtml">
<p>
Run the test. No interaction required.
</p>
</d:operatorScript>
<d:passCriteria xmlns="http://www.w3.org/1999/xhtml">
<p>
The test is passed if each shape seems to have a double stroke, dark green and light green.
</p>
</d:passCriteria>
</d:SVGTestCase>
<title id="test-title">$RCSfile: shapes-polyline-02-t.svg,v $</title>
<defs>
<font-face font-family="SVGFreeSansASCII" unicode-range="U+0-7F">
<font-face-src>
<font-face-uri xlink:href="../resources/SVGFreeSans.svg#ascii"/>
</font-face-src>
</font-face>
</defs>
<g id="test-body-content" font-family="SVGFreeSansASCII,sans-serif" font-size="18">
<g stroke="#070" stroke-width="8" stroke-linejoin="miter">
<!-- Open sawtooth line. -->
<polyline id="polyline-01" fill="none" points="10,50,35,150,60,50,85,150,110,50,135,150"/>
<!-- Closed pentagon shaped polyline (5 segments). -->
<polyline id="polyline-02" fill="none" points="220,50,267,84,249,140,190,140,172,84,220,50"/>
<!-- The sawtooth again, polylines can be filled. -->
<polyline id="polyline-03" fill="#396" points="310,50,335,150,360,50,385,150,410,50,435,150"/>
<!-- An unclosed "septagon" shaped polyline (7th segment omitted). -->
<polyline id="polyline-04" fill="none" points="59,185,98,203,108,245,82,279,39,280,11,247,19,205"/>
<!-- Same shape, filled, shows difference with 'polygon'. -->
<polyline id="polyline-05" fill="#396" points="189,185,228,203,238,245,212,279,169,280,141,247,149,205"/>
<polyline id="polyline-06" fill="#396"
points="270,225 300,245 320,225 340,245 280,280
390,280 420,240 280,185"/>
</g>
<!-- now the equivalent paths-->
<g stroke="#3C6" stroke-width="3" fill="none" stroke-linejoin="bevel">
<path d="M10,50 L35,150,60,50,85,150,110,50,135,150"/>
<path d="M220,50 L267,84,249,140,190,140,172,84,220,50"/>
<path d="M310,50 L335,150,360,50,385,150,410,50,435,150"/>
<path d="M59,185 L98,203,108,245,82,279,39,280,11,247,19,205"/>
<path d="M189,185 L228,203,238,245,212,279,169,280,141,247,149,205"/>
<path d="M270,225 L300,245 320,225 340,245 280,280
390,280 420,240 280,185"/>
</g>
</g>
<g font-family="SVGFreeSansASCII,sans-serif" font-size="32">
<text id="revision" x="10" y="340" stroke="none" fill="black">$Revision: 1.3 $</text>
</g>
<rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000000"/>
<!-- comment out this watermark once the test is approved -->
<!--
<g id="draft-watermark">
<rect x="1" y="1" width="478" height="20" fill="red" stroke="black" stroke-width="1"/>
<text font-family="SVGFreeSansASCII,sans-serif" font-weight="bold" font-size="20" x="240"
text-anchor="middle" y="18" stroke-width="0.5" stroke="black" fill="white">DRAFT</text>
</g>
-->
</svg>

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -4,14 +4,16 @@ open class Stroke {
open let width: Double
open let cap: LineCap
open let join: LineJoin
open let miterLimit: Double
open let dashes: [Double]
open let offset: Double
public init(fill: Fill = Color.black, width: Double = 1, cap: LineCap = .butt, join: LineJoin = .miter, dashes: [Double] = [], offset: Double = 0.0) {
public init(fill: Fill = Color.black, width: Double = 1, cap: LineCap = .butt, join: LineJoin = .miter, miterLimit: Double = 10, dashes: [Double] = [], offset: Double = 0.0) {
self.fill = fill
self.width = width
self.cap = cap
self.join = join
self.miterLimit = miterLimit
self.dashes = dashes
self.offset = offset
}

View File

@ -274,6 +274,7 @@ class ShapeRenderer: NodeRenderer {
ctx!.setLineWidth(CGFloat(stroke.width))
ctx!.setLineJoin(stroke.join.toCG())
ctx!.setLineCap(stroke.cap.toCG())
ctx!.setMiterLimit(CGFloat(stroke.miterLimit))
if !stroke.dashes.isEmpty {
ctx?.setLineDash(phase: CGFloat(stroke.offset),
lengths: stroke.dashes.map { CGFloat($0) })

View File

@ -33,7 +33,7 @@ open class SVGParser {
return SVGParser(text).parse()
}
let availableStyleAttributes = ["stroke", "stroke-width", "stroke-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin",
let availableStyleAttributes = ["stroke", "stroke-width", "stroke-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit",
"fill", "fill-rule", "text-anchor", "clip-path", "fill-opacity",
"stop-color", "stop-opacity",
"font-family", "font-size",
@ -625,6 +625,7 @@ open class SVGParser {
width: getStrokeWidth(styleParts),
cap: getStrokeCap(styleParts),
join: getStrokeJoin(styleParts),
miterLimit: getStrokeMiterLimit(styleParts),
dashes: getStrokeDashes(styleParts),
offset: getStrokeOffset(styleParts))
}
@ -639,6 +640,13 @@ open class SVGParser {
return 1
}
fileprivate func getStrokeMiterLimit(_ styleParts: [String: String]) -> Double {
if let strokeWidth = styleParts["stroke-miterlimit"], let value = doubleFromString(strokeWidth) {
return value
}
return 4
}
fileprivate func getStrokeCap(_ styleParts: [String: String]) -> LineCap {
var cap = LineCap.butt
if let strokeCap = styleParts["stroke-linecap"] {