Skip to content

Commit 8620a32

Browse files
StartAutomatingStartAutomating
authored andcommitted
feat: Turtle.get_SVG ( Fixes PoshWeb#17 )
1 parent ebe9773 commit 8620a32

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

Turtle.types.ps1xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,25 @@ $this | Add-Member -MemberType NoteProperty -Force -Name '.Stroke' -Value $value
221221
$this | Add-Member -MemberType NoteProperty -Force -Name '.StrokeThickness' -Value $value
222222
</SetScriptBlock>
223223
</ScriptProperty>
224+
<ScriptProperty>
225+
<Name>SVG</Name>
226+
<GetScriptBlock>
227+
param()
228+
@(
229+
230+
$viewX = [Math]::Max($this.Maximum.X, $this.Minimum.X * -1)
231+
$viewY = [Math]::Max($this.Maximum.Y, $this.Minimum.Y * -1)
232+
233+
"&lt;svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 $viewX $viewY' transform-origin='50% 50%' width='100%' height='100%'&gt;"
234+
"&lt;path id='turtle-path' transform-origin='50% 50%' d='$($this.PathData)' stroke='$(
235+
if ($this.Stroke) { $this.Stroke } else { '#4488ff' }
236+
)' stroke-thickness='$(
237+
if ($this.StrokeThickness) { $this.StrokeThickness } else { '0.1%' }
238+
)' fill='transparent'/&gt;"
239+
"&lt;/svg&gt;"
240+
) -join '' -as [xml]
241+
</GetScriptBlock>
242+
</ScriptProperty>
224243
</Members>
225244
</Type>
226245
</Types>

0 commit comments

Comments
 (0)