Skip to content

Commit 1dbab7f

Browse files
feat: Shape.CSS ( Fixes #5 )
1 parent 83895fe commit 1dbab7f

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

Types/Shape/get_CSS.ps1

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<#
2+
.SYNOPSIS
3+
Gets Shapes as CSS
4+
.DESCRIPTION
5+
Gets the Shape as CSS.
6+
.EXAMPLE
7+
shape circle 50% |
8+
Select-Object -Expand CSS
9+
#>
10+
param()
11+
12+
$ShapeType = 'shape'
13+
14+
# Get our gradient type
15+
$ShapeType = $this.ShapeType
16+
$shapeValues = @(foreach ($in in $this.input) {
17+
if ($in -notmatch $this.ShapeTypePattern) {
18+
$in
19+
}
20+
})
21+
22+
if (-not $ShapeType) { $ShapeType = 'shape'}
23+
24+
if ($ShapeType -eq 'polygon') {
25+
return "polygon($(
26+
@(for ($valueIndex = 0; $valueIndex -lt $shapeValues.Count; $valueIndex += 2) {
27+
@(if ($null -ne $shapeValues[$valueIndex + 1]) {
28+
$shapeValues[$valueIndex]
29+
$shapeValues[$valueIndex + 1]
30+
} else {
31+
$shapeValues[$valueIndex]
32+
$shapeValues[$valueIndex]
33+
}) -join ' '
34+
}) -join ', '
35+
))"
36+
}
37+
38+
$joinWith = if ($ShapeType -notin 'shape') {
39+
' '
40+
} else {
41+
', '
42+
}
43+
44+
"$shapeType($(
45+
@(
46+
$shapeValues
47+
) -join $joinWith
48+
))"

0 commit comments

Comments
 (0)