Skip to content

Commit c6db8d6

Browse files
Merge pull request #135 from StartAutomating/PSSVG-Updates
PSSVG 0.2.10
2 parents 8e14e60 + 06292d0 commit c6db8d6

File tree

140 files changed

+2289
-800
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+2289
-800
lines changed
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11

2-
name: OnIssueChanged
2+
name: GitPub
33
on:
4-
issues:
54
workflow_dispatch:
65
jobs:
76
RunGitPub:

.github/workflows/TestAndPublish.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -579,13 +579,21 @@ jobs:
579579
- name: PipeScript
580580
uses: StartAutomating/PipeScript@main
581581
id: PipeScript
582-
- name: Use PSSVG Action
582+
- name: Use PSSVG (from main)
583+
if: ${{github.ref_name == 'main'}}
583584
uses: StartAutomating/PSSVG@main
584-
id: PSSVG
585+
id: PSSVGMain
586+
- name: Use PSSVG (on branch)
587+
if: ${{github.ref_name != 'main'}}
588+
uses: ./
589+
id: PSSVGBranch
590+
- name: GitLogger
591+
uses: GitLogging/GitLoggerAction@main
592+
id: GitLogger
585593
- name: UseEZOut
586594
uses: StartAutomating/EZOut@master
587595
- name: UseHelpOut
588596
uses: StartAutomating/HelpOut@master
589597
env:
590-
NoCoverage: true
591598
GIT_TOKEN: ${{secrets.GITHUB_TOKEN}}
599+
NoCoverage: true

Assets/PSSVG.svg

Lines changed: 1 addition & 1 deletion
Loading

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
### PSSVG 0.2.10:
2+
3+
* Write-SVG - Fixing -ViewBox for string values (#127)
4+
* Adding -ShapeName and many aliases to SVG.ConvexPolygon (#132)
5+
* Adding HexagonPattern Example (#133)
6+
* Adding more RepeatedShapes (with less black background) (#129)
7+
8+
---
9+
110
### PSSVG 0.2.9:
211

312
* New Examples:

Commands/Common/Write-SVG.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
# The only attribute we treat that specially is -Viewbox.
9696
if ($paramName -eq 'Viewbox') {
9797
# For that, we basically pad out whatever list was provided to make four coordinates.
98-
$viewBoxLeft, $viewBoxTop, $viewBoxRight, $viewBoxBottom = $paramValue -as [double[]]
98+
$viewBoxLeft, $viewBoxTop, $viewBoxRight, $viewBoxBottom = $paramValue -split '\s' -as [double[]]
9999
$paramValue = @(if ($null -eq $viewBoxTop) {
100100
0,0,$viewBoxLeft,$viewBoxLeft
101101
} elseif ($null -eq $viewBoxRight) {

Commands/Shapes/SVG.ConvexPolygon.ps.ps1

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,42 @@ function SVG.ConvexPolygon {
1414
'SVG.Path'
1515
}, Abstract,Dynamic, ExcludeParameter='D')]
1616
[CmdletBinding(PositionalBinding=$false)]
17+
[Alias('SVG.Pentagon',
18+
'SVG.Hexagon','SVG.Heptagon','SVG.Octagon',
19+
'SVG.Nonagon','SVG.Decagon','SVG.Decagon',
20+
'SVG.Hendecagon', 'SVG.Dodecagon','SVG.Tridecagon',
21+
'SVG.Tetradecagon','SVG.Pentadecagon','SVG.Hexadecagon',
22+
'SVG.Heptadecagon','SVG.Octadecagon','SVG.Enneadecagon',
23+
'SVG.Icosagon','SVG.Icosikaihenagon','SVG.Icosikaidigon',
24+
'SVG.Icositrigon','SVG.Icositetragon','SVG.Icosikaipentagon',
25+
'SVG.Icosikaihexagon','SVG.Icosikaiheptagon','SVG.Icosikaioctagon',
26+
'SVG.Icosikaienneagon','SVG.Triacontagon')]
1727
param(
1828
# The number of sides in the polygon
1929
# This is also aliased to -PointCount for consistent use with SVG.Star.
2030
[Parameter(ValueFromPipelineByPropertyName,Position=0)]
2131
[Alias('NumberOfSides','SC','Sides','NumSides','PC','D','PointCount')]
2232
[ValidateRange(3,360)]
2333
[int]
24-
$SideCount,
34+
$SideCount = 3,
35+
36+
# The formal name of the shape, for example Pentagon.
37+
# Note, for ease of calculation, only shapes with sides between three and thirty accept their names.
38+
# (aka, No Hectagons or Megagons)
39+
[Parameter(ValueFromPipelineByPropertyName)]
40+
[ValidateSet('Triangle','Rectangle','Pentagon',
41+
'Hexagon','Heptagon','Octagon',
42+
'Nonagon','Decagon','Decagon',
43+
'Hendecagon', 'Dodecagon','Tridecagon',
44+
'Tetradecagon','Pentadecagon','Hexadecagon',
45+
'Heptadecagon','Octadecagon','Enneadecagon',
46+
'Icosagon','Icosikaihenagon','Icosikaidigon',
47+
'Icositrigon','Icositetragon','Icosikaipentagon',
48+
'Icosikaihexagon','Icosikaiheptagon','Icosikaioctagon',
49+
'Icosikaienneagon','Triacontagon'
50+
)]
51+
[string]
52+
$ShapeName,
2553

2654
# The initial rotation of the polygon.
2755
[Parameter(ValueFromPipelineByPropertyName)]
@@ -49,6 +77,18 @@ function SVG.ConvexPolygon {
4977
)
5078

5179
process {
80+
if (-not $PSBoundParameters['SideCount'] -and
81+
($MyInvocation.InvocationName -ne $MyInvocation.MyCommand.Name)) {
82+
$shapeValues = @($MyInvocation.MyCommand.Parameters['ShapeName'].Attributes.ValidValues)
83+
84+
for ($shapeNumber = 0; $shapeNumber -lt $shapeValues.Length;$shapeNumber++) {
85+
if ($MyInvocation.InvocationName -eq "SVG.$($shapeValues[$shapeNumber])") {
86+
$SideCount = $shapeNumber + 3
87+
break
88+
}
89+
}
90+
}
91+
5292
# We can construct a regular polygon by creating N points along a unit circle
5393
$anglePerPoint = 360 / $SideCount
5494
$r = $Radius

Commands/Shapes/SVG.ConvexPolygon.ps1

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,42 @@ function SVG.ConvexPolygon {
1212
1313
#>
1414

15-
[CmdletBinding(PositionalBinding=$false)]
15+
[CmdletBinding(PositionalBinding=$false)]
16+
[Alias('SVG.Pentagon',
17+
'SVG.Hexagon','SVG.Heptagon','SVG.Octagon',
18+
'SVG.Nonagon','SVG.Decagon','SVG.Decagon',
19+
'SVG.Hendecagon', 'SVG.Dodecagon','SVG.Tridecagon',
20+
'SVG.Tetradecagon','SVG.Pentadecagon','SVG.Hexadecagon',
21+
'SVG.Heptadecagon','SVG.Octadecagon','SVG.Enneadecagon',
22+
'SVG.Icosagon','SVG.Icosikaihenagon','SVG.Icosikaidigon',
23+
'SVG.Icositrigon','SVG.Icositetragon','SVG.Icosikaipentagon',
24+
'SVG.Icosikaihexagon','SVG.Icosikaiheptagon','SVG.Icosikaioctagon',
25+
'SVG.Icosikaienneagon','SVG.Triacontagon')]
1626
param(
1727
# The number of sides in the polygon
1828
# This is also aliased to -PointCount for consistent use with SVG.Star.
1929
[Parameter(ValueFromPipelineByPropertyName,Position=0)]
2030
[Alias('NumberOfSides','SC','Sides','NumSides','PC','D','PointCount')]
2131
[ValidateRange(3,360)]
2232
[int]
23-
$SideCount,
33+
$SideCount = 3,
34+
# The formal name of the shape, for example Pentagon.
35+
# Note, for ease of calculation, only shapes with sides between three and thirty accept their names.
36+
# (aka, No Hectagons or Megagons)
37+
[Parameter(ValueFromPipelineByPropertyName)]
38+
[ValidateSet('Triangle','Rectangle','Pentagon',
39+
'Hexagon','Heptagon','Octagon',
40+
'Nonagon','Decagon','Decagon',
41+
'Hendecagon', 'Dodecagon','Tridecagon',
42+
'Tetradecagon','Pentadecagon','Hexadecagon',
43+
'Heptadecagon','Octadecagon','Enneadecagon',
44+
'Icosagon','Icosikaihenagon','Icosikaidigon',
45+
'Icositrigon','Icositetragon','Icosikaipentagon',
46+
'Icosikaihexagon','Icosikaiheptagon','Icosikaioctagon',
47+
'Icosikaienneagon','Triacontagon'
48+
)]
49+
[string]
50+
$ShapeName,
2451
# The initial rotation of the polygon.
2552
[Parameter(ValueFromPipelineByPropertyName)]
2653
[Alias('Rotation')]
@@ -77,6 +104,18 @@ function SVG.ConvexPolygon {
77104
$DynamicParameters
78105
}
79106
process {
107+
if (-not $PSBoundParameters['SideCount'] -and
108+
($MyInvocation.InvocationName -ne $MyInvocation.MyCommand.Name)) {
109+
$shapeValues = @($MyInvocation.MyCommand.Parameters['ShapeName'].Attributes.ValidValues)
110+
111+
for ($shapeNumber = 0; $shapeNumber -lt $shapeValues.Length;$shapeNumber++) {
112+
if ($MyInvocation.InvocationName -eq "SVG.$($shapeValues[$shapeNumber])") {
113+
$SideCount = $shapeNumber + 3
114+
break
115+
}
116+
}
117+
}
118+
80119
# We can construct a regular polygon by creating N points along a unit circle
81120
$anglePerPoint = 360 / $SideCount
82121
$r = $Radius

Commands/Standard/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
This directory contains the commands that directly map to elements in the SVG standard.
22

3-
It was last synchronized to the standard @ 2023-07-04T20:29:55.6205852Z
3+
It was last synchronized to the standard @ 2023-07-08T04:00:55.6853961Z

Commands/Standard/SVG.animate.ps1

Lines changed: 37 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,86 +1509,8 @@ function SVG.animate {
15091509
.Example
15101510
svg -Content @(
15111511
svg.polygon -Points "25,50 50,75 75,50 50,25" -Fill '#4488ff' @(
1512-
svg.animate -AttributeName points -to "0,0 0,100 100,100, 100,0" -Dur 2s -Id morph1 -Begin '0s;morph2.end' -AttributeType XML
1513-
svg.animate -AttributeName opacity -Values '0' -Dur '0.0s' -Begin 'morph1.end' -AttributeType XML
1514-
svg.animate -AttributeName opacity -Values '1' -Dur '0.0s' -Begin 'morph1.end' -AttributeType XML
1512+
svg.animate -AttributeName points -Values "25,50 50,75 75,50 50,25;0,0 0,100 100,100, 100,0; 25,50 50,75 75,50 50,25" -Dur 2s -Id morph1 -RepeatCount 'indefinite' -AttributeType XML
15151513
)
1516-
svg.polygon -Points "0,0 0,100 100,100, 100,0" -Fill '#4488ff' @(
1517-
svg.animate -AttributeName opacity -Values '1' -Dur '0.0s' -Begin 'morph1.end' -AttributeType XML
1518-
svg.animate -AttributeName points -to "25,50 50,75 75,50 50,25" -Dur 2s -Id morph2 -Begin 'morph1.end' -AttributeType XML
1519-
svg.animate -AttributeName opacity -Values '0' -Dur '0.0s' -Begin 'morph2.end' -AttributeType XML
1520-
) -Opacity 0
1521-
1522-
) -ViewBox 100,100
1523-
.Example
1524-
svg -Content @(
1525-
svg.polygon -Points "25,50 50,75 75,50 50,25" -Fill '#4488ff' @(
1526-
svg.animate -AttributeName points -to "0,0 0,100 100,100, 100,0" -Dur 2s -Id morph1 -Begin '0s;morph2.end' -AttributeType XML
1527-
svg.animate -AttributeName opacity -Values '0' -Dur '0.0s' -Begin 'morph1.end' -AttributeType XML
1528-
svg.animate -AttributeName opacity -Values '1' -Dur '0.0s' -Begin 'morph1.end' -AttributeType XML
1529-
)
1530-
svg.polygon -Points "0,0 0,100 100,100, 100,0" -Fill '#4488ff' @(
1531-
svg.animate -AttributeName opacity -Values '1' -Dur '0.0s' -Begin 'morph1.end' -AttributeType XML
1532-
svg.animate -AttributeName points -to "25,50 50,75 75,50 50,25" -Dur 2s -Id morph2 -Begin 'morph1.end' -AttributeType XML
1533-
svg.animate -AttributeName opacity -Values '0' -Dur '0.0s' -Begin 'morph2.end' -AttributeType XML
1534-
) -Opacity 0
1535-
1536-
) -ViewBox 100,100
1537-
.Example
1538-
svg -Content @(
1539-
svg.polygon -Points "25,50 50,75 75,50 50,25" -Fill '#4488ff' @(
1540-
svg.animate -AttributeName points -to "0,0 0,100 100,100, 100,0" -Dur 2s -Id morph1 -Begin '0s;morph2.end' -AttributeType XML
1541-
svg.animate -AttributeName opacity -Values '0' -Dur '0.0s' -Begin 'morph1.end' -AttributeType XML
1542-
svg.animate -AttributeName opacity -Values '1' -Dur '0.0s' -Begin 'morph1.end' -AttributeType XML
1543-
)
1544-
svg.polygon -Points "0,0 0,100 100,100, 100,0" -Fill '#4488ff' @(
1545-
svg.animate -AttributeName opacity -Values '1' -Dur '0.0s' -Begin 'morph1.end' -AttributeType XML
1546-
svg.animate -AttributeName points -to "25,50 50,75 75,50 50,25" -Dur 2s -Id morph2 -Begin 'morph1.end' -AttributeType XML
1547-
svg.animate -AttributeName opacity -Values '0' -Dur '0.0s' -Begin 'morph2.end' -AttributeType XML
1548-
) -Opacity 0
1549-
1550-
) -ViewBox 100,100
1551-
.Example
1552-
svg -Content @(
1553-
svg.polygon -Points "25,50 50,75 75,50 50,25" -Fill '#4488ff' @(
1554-
svg.animate -AttributeName points -to "0,0 0,100 100,100, 100,0" -Dur 2s -Id morph1 -Begin '0s;morph2.end' -AttributeType XML
1555-
svg.animate -AttributeName opacity -Values '0' -Dur '0.0s' -Begin 'morph1.end' -AttributeType XML
1556-
svg.animate -AttributeName opacity -Values '1' -Dur '0.0s' -Begin 'morph1.end' -AttributeType XML
1557-
)
1558-
svg.polygon -Points "0,0 0,100 100,100, 100,0" -Fill '#4488ff' @(
1559-
svg.animate -AttributeName opacity -Values '1' -Dur '0.0s' -Begin 'morph1.end' -AttributeType XML
1560-
svg.animate -AttributeName points -to "25,50 50,75 75,50 50,25" -Dur 2s -Id morph2 -Begin 'morph1.end' -AttributeType XML
1561-
svg.animate -AttributeName opacity -Values '0' -Dur '0.0s' -Begin 'morph2.end' -AttributeType XML
1562-
) -Opacity 0
1563-
1564-
) -ViewBox 100,100
1565-
.Example
1566-
svg -Content @(
1567-
svg.polygon -Points "25,50 50,75 75,50 50,25" -Fill '#4488ff' @(
1568-
svg.animate -AttributeName points -to "0,0 0,100 100,100, 100,0" -Dur 2s -Id morph1 -Begin '0s;morph2.end' -AttributeType XML
1569-
svg.animate -AttributeName opacity -Values '0' -Dur '0.0s' -Begin 'morph1.end' -AttributeType XML
1570-
svg.animate -AttributeName opacity -Values '1' -Dur '0.0s' -Begin 'morph1.end' -AttributeType XML
1571-
)
1572-
svg.polygon -Points "0,0 0,100 100,100, 100,0" -Fill '#4488ff' @(
1573-
svg.animate -AttributeName opacity -Values '1' -Dur '0.0s' -Begin 'morph1.end' -AttributeType XML
1574-
svg.animate -AttributeName points -to "25,50 50,75 75,50 50,25" -Dur 2s -Id morph2 -Begin 'morph1.end' -AttributeType XML
1575-
svg.animate -AttributeName opacity -Values '0' -Dur '0.0s' -Begin 'morph2.end' -AttributeType XML
1576-
) -Opacity 0
1577-
1578-
) -ViewBox 100,100
1579-
.Example
1580-
svg -Content @(
1581-
svg.polygon -Points "25,50 50,75 75,50 50,25" -Fill '#4488ff' @(
1582-
svg.animate -AttributeName points -to "0,0 0,100 100,100, 100,0" -Dur 2s -Id morph1 -Begin '0s;morph2.end' -AttributeType XML
1583-
svg.animate -AttributeName opacity -Values '0' -Dur '0.0s' -Begin 'morph1.end' -AttributeType XML
1584-
svg.animate -AttributeName opacity -Values '1' -Dur '0.0s' -Begin 'morph1.end' -AttributeType XML
1585-
)
1586-
svg.polygon -Points "0,0 0,100 100,100, 100,0" -Fill '#4488ff' @(
1587-
svg.animate -AttributeName opacity -Values '1' -Dur '0.0s' -Begin 'morph1.end' -AttributeType XML
1588-
svg.animate -AttributeName points -to "25,50 50,75 75,50 50,25" -Dur 2s -Id morph2 -Begin 'morph1.end' -AttributeType XML
1589-
svg.animate -AttributeName opacity -Values '0' -Dur '0.0s' -Begin 'morph2.end' -AttributeType XML
1590-
) -Opacity 0
1591-
15921514
) -ViewBox 100,100
15931515
.Example
15941516
svg -Content @(
@@ -1692,14 +1614,14 @@ function SVG.animate {
16921614
[float]$CenterY = 100,
16931615
# The radius coordinate of the shape. This will decrease by 1/RepeatCount each time.
16941616
[float]$Radius = 100,
1695-
# The number of sides
1696-
$SideCount = 3,
1617+
# The number of sides. A file will be generated for each unique value provided.
1618+
[int[]]$SideCount = 3..6,
16971619
# The total rotation of the innermost element,
16981620
$TotalRotation = 180,
16991621
# The total duration of any animations.
17001622
[timespan]$duration = '00:00:03.75',
17011623
# A palette of colors to alternate thru
1702-
[string[]]$colors = @('#112244','#224488',"#4488ff"),
1624+
[string[]]$Color = @('#112244','#224488',"#4488ff"),
17031625
# The type of the shape. (either Star or ConvexPolygon)
17041626
[ValidateSet("Star", "ConvexPolygon")]
17051627
[string]
@@ -1710,36 +1632,37 @@ function SVG.animate {
17101632
$AnimateOpacity
17111633
)
17121634
1713-
$Splat = [Ordered]@{
1714-
SideCount = $SideCount
1715-
Fill = 'transparent'
1716-
CenterX = $CenterX
1717-
CenterY = $CenterY
1718-
}
17191635
17201636
$shapeCommand = $ExecutionContext.SessionState.InvokeCommand.GetCommand("SVG.$ShapeType", "Function")
1721-
SVG -ViewBox (($CenterX * 2), ($CenterY * 2)) @(
1722-
SVG.rect -Width 1000% -Height 1000% -X -500% -Y -500% -Fill 'black'
1723-
1724-
0..($RepeatCount -1) |
1725-
. $shapeCommand @Splat -Rotate {
1726-
$_ * ($totalRotation / $RepeatCount)
1727-
} -Radius {
1728-
$Radius - (
1729-
$_ * ($Radius / $RepeatCount)
1730-
)
1731-
} -Stroke {
1732-
$colors[$_ % $colors.Length]
1733-
} -Children {
1734-
$toRotation = $(360 * ([Math]::Ceiling(($_ + 1)/10)))
1735-
SVG.animateTransform -From "0 $centerX $centerY" -To "$toRotation $centerX $centerY" -Dur $duration -AttributeName transform -Type 'rotate' -RepeatCount 'indefinite'
1736-
$lowOpacity = [double]($_)/$RepeatCount
1737-
$highOpacity = 1.0 - [double]($_)/$RepeatCount
1738-
if ($AnimateOpacity) {
1739-
SVG.animate -AttributeName opacity -Values "$highOpacity;$lowOpacity;$highOpacity" -Dur $dur -RepeatCount 'indefinite'
1637+
1638+
foreach ($Sides in $SideCount) {
1639+
$Splat = [Ordered]@{
1640+
SideCount = $Sides
1641+
Fill = 'transparent'
1642+
CenterX = $CenterX
1643+
CenterY = $CenterY
1644+
}
1645+
1646+
SVG -ViewBox (($CenterX * 2), ($CenterY * 2)) @(
1647+
0..($RepeatCount -1) |
1648+
& $shapeCommand @Splat -Rotate {
1649+
$_ * ($totalRotation / $RepeatCount)
1650+
} -Radius {
1651+
$Radius - (
1652+
$_ * ($Radius / $RepeatCount)
1653+
)
1654+
} -Stroke {
1655+
$Color[$_ % $color.Length]
1656+
} -Children {
1657+
$toRotation = $(360 * ([Math]::Ceiling(($_ + 1)/10)))
1658+
SVG.animateTransform -From "0 $centerX $centerY" -To "$toRotation $centerX $centerY" -Dur $duration -AttributeName transform -Type 'rotate' -RepeatCount 'indefinite'
1659+
$lowOpacity = [double]($_)/$RepeatCount
1660+
$highOpacity = 1.0 - [double]($_)/$RepeatCount
1661+
if ($AnimateOpacity) {
1662+
SVG.animate -AttributeName opacity -Values "$highOpacity;$lowOpacity;$highOpacity" -Dur $dur -RepeatCount 'indefinite'
1663+
}
17401664
}
1741-
}
1742-
)
1665+
)
17431666
.Example
17441667
svg @(
17451668
svg.ConvexPolygon -SideCount 8 -Rotate (360/16) -Fill '#dd0000' -Stroke white -CenterX 100 -CenterY 100 -Radius 100
@@ -1800,6 +1723,11 @@ function SVG.animate {
18001723
svg.animate -Values '28;30;28' -Dur 5s -AttributeName font-size -RepeatDur 'indefinite'
18011724
)
18021725
) -ViewBox 200,200
1726+
.Example
1727+
svg @(
1728+
svg.ConvexPolygon -SideCount 8 -Rotate (360/16) -Fill '#4488ff' -Stroke '#4488ff' -CenterX 100 -CenterY 100 -Radius 50
1729+
SVG.animate -AttributeName viewBox -Values "0 0 200 200; 50 50 100 100; 0 0 200 200" -RepeatCount 'indefinite' -Dur 3.9
1730+
) -ViewBox 200,200
18031731
.Link
18041732
https://pssvg.start-automating.com/SVG.animate
18051733
.Link

0 commit comments

Comments
 (0)