@@ -22,11 +22,23 @@ if ($this.ViewBox[-1] -eq 0 -or $this.ViewBox[-2] -eq 0) {
2222}
2323
2424# Any explicitly provided attributes should override any automatic attributes.
25+
26+ # These can come from .Attribute
27+ foreach ($key in $this.Attribute.Keys ) {
28+ if ($key -match ' ^svg/' ) { # (as long as they start with `svg/`)
29+ $svgAttributes [$key -replace ' ^svg/' ] = $this.Attribute [$key ]
30+ }
31+ }
32+
33+ # They can also come from SVGAttribute
2534foreach ($key in $this.SVGAttribute.Keys ) {
2635 $svgAttributes [$key ] = $this.SVGAttribute [$key ]
2736}
2837
38+
39+
2940" <svg $ ( @ (foreach ($attributeName in $svgAttributes.Keys ) {
41+ if ($attributeName -match ' /' ) { continue }
3042 " $attributeName ='$ ( $svgAttributes [$attributeName ]) '"
3143}) -join ' ' ) >"
3244 # Declare any definitions, like markers or gradients.
@@ -35,19 +47,47 @@ foreach ($key in $this.SVGAttribute.Keys) {
3547 $this.Defines
3648 " </defs>"
3749 }
50+
51+ if ($this.Keyframe -or $this.Style ) {
52+ $keyframe = $this.Keyframe
53+ " <style>"
54+ @ (foreach ($keyframeName in $keyframe.Keys ) {
55+ $keyframeKeyframes = $keyframe [$keyframeName ]
56+ " @keyframes $keyframeName {"
57+ foreach ($percent in $keyframeKeyframes.Keys ) {
58+ " $percent {"
59+ $props = $keyframeKeyframes [$percent ]
60+ foreach ($prop in $props.Keys ) {
61+ $value = $props .$prop
62+ " ${prop} : $value ;"
63+ }
64+ " }"
65+ }
66+ " }"
67+ " .$keyframeName {"
68+ " animation-name: $keyframeName ;"
69+ " animation-duration: $ ( $this.Duration.TotalSeconds ) s;"
70+ " animation-iteration-count: infinite;"
71+ " }"
72+ }) -join [Environment ]::NewLine
73+ if ($this.Style ) {
74+ " $ ( $this.Style -join (' ;' + [Environment ]::NewLine)) "
75+ }
76+ " </style>"
77+ }
3878
3979 # Declare any SVG animations
40- if ($this.SVGAnimation ) {$this.SVGAnimation }
80+ if ($this.SVGAnimation ) {$this.SVGAnimation }
81+ if ($this.BackgroundColor ) {
82+ " <rect width='10000%' height='10000%' x='-5000%' y='-5000%' fill='$ ( $this.BackgroundColor ) ' transform-origin='50% 50%' />"
83+ }
4184 if ($this.Link ) {
4285 " <a href='$ ( $this.Link ) '>"
4386 }
4487 # Output our own path
4588 $this.PathElement.OuterXml
4689 # Followed by any text elements
47- $this.TextElement.OuterXml
48- if ($this.Link ) {
49- " </a>"
50- }
90+ $this.TextElement.OuterXml
5191
5292 # If the turtle has children
5393 $children = @ (foreach ($turtleName in $this.Turtles.Keys ) {
@@ -71,5 +111,8 @@ foreach ($key in $this.SVGAttribute.Keys) {
71111 }
72112 " </g>"
73113 }
114+ if ($this.Link ) {
115+ " </a>"
116+ }
74117" </svg>"
75118) -join ' ' -as [xml ]
0 commit comments