Skip to content

Commit 7ee708b

Browse files
feat: Turtle.get/set_Opacity ( Fixes #293 )
1 parent 1ee6259 commit 7ee708b

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

Types/Turtle/get_Opacity.ps1

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
<#
22
.SYNOPSIS
3-
Gets the turtle opacity
3+
Gets a Turtle's opacity
44
.DESCRIPTION
5-
Gets the opacity of the turtle path.
5+
Gets the opacity of a Turtle
6+
.EXAMPLE
7+
turtle opacity .5
68
#>
7-
if (-not $this.'.PathAttribute') {
8-
$this | Add-Member -MemberType NoteProperty -Name '.PathAttribute' -Value ([Ordered]@{}) -Force
9-
}
10-
if ($this.'.PathAttribute'.'opacity') {
11-
return $this.'.PathAttribute'.'opacity'
12-
} else {
13-
return 1.0
14-
}
9+
param()
10+
return $this.'.Opacity'

Types/Turtle/get_SVG.ps1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ $svgAttributes = [Ordered]@{
1515
height='100%'
1616
}
1717

18+
# If opacity is set, it should apply to the entire SVG.
19+
if ($null -ne $this.opacity) {
20+
$svgAttributes['opacity'] = $this.opacity
21+
}
22+
1823
# If the viewbox would have zero width or height
1924
if ($this.ViewBox[-1] -eq 0 -or $this.ViewBox[-2] -eq 0) {
2025
# It's not much of a viewbox at all, and we will omit the attribute.
@@ -73,7 +78,7 @@ $svgElement = @(
7378
"$($this.Style -join (';' + [Environment]::NewLine))"
7479
}
7580
"</style>"
76-
}
81+
}
7782

7883
# Declare any SVG animations
7984
if ($this.SVGAnimation) {$this.SVGAnimation}

Types/Turtle/set_Opacity.ps1

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
<#
22
.SYNOPSIS
3-
Sets the opacity
3+
Sets a Turtle's opacity
44
.DESCRIPTION
5-
Sets the opacity of the path
5+
Sets the opacity of a Turtle
66
.EXAMPLE
7-
turtle forward 100 opacity 0.5 save ./dimLine.svg
7+
turtle opacity .5 opacity
88
#>
99
param(
1010
[double]
11-
$Opacity = 'nonzero'
11+
$Opacity
1212
)
13-
14-
$this.PathAttribute = [Ordered]@{'opacity' = $Opacity}
13+
$this | Add-Member NoteProperty '.Opacity' $Opacity -Force

0 commit comments

Comments
 (0)