Skip to content

Commit 7ff406e

Browse files
StartAutomatingStartAutomating
authored andcommitted
feat: Turtle.get/set_Opacity ( Fixes #293 )
1 parent 7ee708b commit 7ff406e

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

Turtle.types.ps1xml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5522,34 +5522,29 @@ param()
55225522
<GetScriptBlock>
55235523
&lt;#
55245524
.SYNOPSIS
5525-
Gets the turtle opacity
5525+
Gets a Turtle's opacity
55265526
.DESCRIPTION
5527-
Gets the opacity of the turtle path.
5527+
Gets the opacity of a Turtle
5528+
.EXAMPLE
5529+
turtle opacity .5
55285530
#&gt;
5529-
if (-not $this.'.PathAttribute') {
5530-
$this | Add-Member -MemberType NoteProperty -Name '.PathAttribute' -Value ([Ordered]@{}) -Force
5531-
}
5532-
if ($this.'.PathAttribute'.'opacity') {
5533-
return $this.'.PathAttribute'.'opacity'
5534-
} else {
5535-
return 1.0
5536-
}
5531+
param()
5532+
return $this.'.Opacity'
55375533
</GetScriptBlock>
55385534
<SetScriptBlock>
55395535
&lt;#
55405536
.SYNOPSIS
5541-
Sets the opacity
5537+
Sets a Turtle's opacity
55425538
.DESCRIPTION
5543-
Sets the opacity of the path
5539+
Sets the opacity of a Turtle
55445540
.EXAMPLE
5545-
turtle forward 100 opacity 0.5 save ./dimLine.svg
5541+
turtle opacity .5 opacity
55465542
#&gt;
55475543
param(
55485544
[double]
5549-
$Opacity = 'nonzero'
5545+
$Opacity
55505546
)
5551-
5552-
$this.PathAttribute = [Ordered]@{'opacity' = $Opacity}
5547+
$this | Add-Member NoteProperty '.Opacity' $Opacity -Force
55535548

55545549
</SetScriptBlock>
55555550
</ScriptProperty>
@@ -6532,6 +6527,11 @@ $svgAttributes = [Ordered]@{
65326527
height='100%'
65336528
}
65346529

6530+
# If opacity is set, it should apply to the entire SVG.
6531+
if ($null -ne $this.opacity) {
6532+
$svgAttributes['opacity'] = $this.opacity
6533+
}
6534+
65356535
# If the viewbox would have zero width or height
65366536
if ($this.ViewBox[-1] -eq 0 -or $this.ViewBox[-2] -eq 0) {
65376537
# It's not much of a viewbox at all, and we will omit the attribute.
@@ -6590,7 +6590,7 @@ $svgElement = @(
65906590
"$($this.Style -join (';' + [Environment]::NewLine))"
65916591
}
65926592
"&lt;/style&gt;"
6593-
}
6593+
}
65946594

65956595
# Declare any SVG animations
65966596
if ($this.SVGAnimation) {$this.SVGAnimation}

0 commit comments

Comments
 (0)