File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ <#
2+ . SYNOPSIS
3+ Gets the turtle as a Marker
4+ . DESCRIPTION
5+ Gets the Turtle as a `<marker>`, which can mark points on another shape.
6+ . EXAMPLE
7+ turtle viewbox 200 teleport 0 100 forward 100 markerEnd (
8+ turtle viewbox 10 rotate -90 polygon 10 3 fill context-fill stroke context-stroke
9+ ) strokewidth '3%' save ./marker.svg
10+ . LINK
11+ https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Element/marker
12+ #>
13+ param ()
14+
15+ # The default settings for markers
16+ $markerAttributes = [Ordered ]@ {
17+ id = " $ ( $this.id ) -marker"
18+ viewBox = " $ ( $this.ViewBox ) "
19+ orient = ' auto-start-reverse'
20+ refX = 0
21+ refY = $this.Height / 2
22+ markerWidth = 5
23+ marketHeight = 5
24+ }
25+ # Marker attributes can exist in .Attribute or .SVGAttribute
26+ $prefix = [Regex ]::new(' ^/?marker/' , ' IgnoreCase' )
27+ foreach ($collection in $this.Attribute , $this.SVGAttribute ) {
28+ foreach ($key in $collection.Keys ) {
29+ if ($key -notmatch $prefix ) { continue }
30+ $markerAttributes [$key -replace $prefix ] = $collection [$key ]
31+ }
32+ }
33+
34+ # Create a marker XML.
35+ [xml ]@ (
36+ " <marker$ (
37+ foreach ($key in $markerAttributes.Keys ) {
38+ " $key ='$ ( $markerAttributes [$key ]) '"
39+ }
40+ ) >"
41+ $this.SVG.SVG.InnerXML
42+ " </marker>"
43+ )
You can’t perform that action at this time.
0 commit comments