Skip to content

Commit 639633b

Browse files
committed
SVGData: path should inherit stroke, fill, and stroke-width from the parent group (closes #32)
1 parent a2d4905 commit 639633b

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

format/svg/SVGData.hx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,36 @@ class SVGData extends Group {
541541

542542
styles.set("opacity", opacity);
543543

544+
}
545+
if (inG.exists("stroke")) {
546+
547+
var stroke = inG.get("stroke");
548+
549+
if (styles == null)
550+
styles = new StringMap<String>();
551+
552+
styles.set("stroke", stroke);
553+
554+
}
555+
if (inG.exists("stroke-width")) {
556+
557+
var strokeWidth = inG.get("stroke-width");
558+
559+
if (styles == null)
560+
styles = new StringMap<String>();
561+
562+
styles.set("stroke-width", strokeWidth);
563+
564+
}
565+
if (inG.exists("fill")) {
566+
567+
var fill = inG.get("fill");
568+
569+
if (styles == null)
570+
styles = new StringMap<String>();
571+
572+
styles.set("fill", fill);
573+
544574
}
545575

546576
for (el in inG.elements ()) {
1.2 KB
Loading

test/images/group-inherited.svg

Lines changed: 8 additions & 0 deletions
Loading

test/src/SvgGenerationTest.hx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ class SvgGenerationTest extends Test
7171
generateAndCompare("path-two-float-decimals.svg");
7272
}
7373

74+
public function testGroupInherited()
75+
{
76+
generateAndCompare("group-inherited.svg");
77+
}
78+
7479
public function testFancySunIconRendersCorrectly()
7580
{
7681
generateAndCompare("fancy-sun.svg");

0 commit comments

Comments
 (0)