StartAutomating/PSSVG

Script SVGs with PowerShell

PowerShell

45

29 commits

updated Aug 24, 2024

See the code

README

PowerShell tools for SVG.

PSSVG helps you create Scalable Vector Graphics using PowerShell.

There is a command for every tag of the SVG standard (and then some).

For example, this script generates the image below it.

svg (
    svg.text -X 50% -Y 50% -Fontsize 36 "Hello World" -DominantBaseline middle -TextAnchor middle -Fill '#4488ff'
) -ViewBox 0,0, 200, 100

PSSVG has a lot cooler Examples than hello world:

PSSVG is designed to act as a fairly complete domain specific language: every aspect of the SVG standard should be reflected in the commands of PSSVG.

The following commands are supported:

ElementFunctionAliases
aSVG.a=<svg.a>
animateSVG.animate=<svg.animate>
animateMotionSVG.animateMotion=<svg.animateMotion>
animateTransformSVG.animateTransform=<svg.animateTransform>
ANSISVG.ANSI=<svg.ANSI>
ArcPathSVG.ArcPath=<SVG.ArcedPath> =<svg.ArcPath> SVG.ArcedPath
circleSVG.circle=<svg.circle>
clipPathSVG.clipPath=<svg.clipPath>
ConvexPolygonSVG.ConvexPolygon=<svg.ConvexPolygon> SVG.Decagon SVG.Dodecagon SVG.Enneadecagon SVG.Hendecagon SVG.Heptadecagon SVG.Heptagon SVG.Hexadecagon SVG.Hexagon SVG.Icosagon SVG.Icosikaidigon SVG.Icosikaienneagon SVG.Icosikaihenagon SVG.Icosikaiheptagon SVG.Icosikaihexagon SVG.Icosikaioctagon SVG.Icosikaipentagon SVG.Icositetragon SVG.Icositrigon SVG.Nonagon SVG.Octadecagon SVG.Octagon SVG.Pentadecagon SVG.Pentagon SVG.Tetradecagon SVG.Triacontagon SVG.Tridecagon
CurvePathSVG.CurvePath=<SVG.CurvedPath> =<svg.CurvePath> SVG.CurvedPath
defsSVG.defs=<svg.defs>
descSVG.desc=<svg.desc>
discardSVG.discard=<svg.discard>
DropShadowSVG.DropShadow=<svg.DropShadow>
ellipseSVG.ellipse=<svg.ellipse>
feBlendSVG.feBlend=<svg.feBlend>
feColorMatrixSVG.feColorMatrix=<svg.feColorMatrix>
feComponentTransferSVG.feComponentTransfer=<svg.feComponentTransfer>
feCompositeSVG.feComposite=<svg.feComposite>
feConvolveMatrixSVG.feConvolveMatrix=<svg.feConvolveMatrix>
feDiffuseLightingSVG.feDiffuseLighting=<svg.feDiffuseLighting>
feDisplacementMapSVG.feDisplacementMap=<svg.feDisplacementMap>
feDistantLightSVG.feDistantLight=<svg.feDistantLight>
feDropShadowSVG.feDropShadow=<svg.feDropShadow>
feFloodSVG.feFlood=<svg.feFlood>
feFuncASVG.feFuncA=<svg.feFuncA>
feFuncBSVG.feFuncB=<svg.feFuncB>
feFuncGSVG.feFuncG=<svg.feFuncG>
feFuncRSVG.feFuncR=<svg.feFuncR>
feGaussianBlurSVG.feGaussianBlur=<svg.feGaussianBlur>
feImageSVG.feImage=<svg.feImage>
feMergeSVG.feMerge=<svg.feMerge>
feMergeNodeSVG.feMergeNode=<svg.feMergeNode>
feMorphologySVG.feMorphology=<svg.feMorphology>
feOffsetSVG.feOffset=<svg.feOffset>
fePointLightSVG.fePointLight=<svg.fePointLight>
feSpecularLightingSVG.feSpecularLighting=<svg.feSpecularLighting>
feSpotLightSVG.feSpotLight=<svg.feSpotLight>
feTileSVG.feTile=<svg.feTile>
feTurbulenceSVG.feTurbulence=<svg.feTurbulence>
filterSVG.filter=<svg.filter>
foreignObjectSVG.foreignObject=<svg.foreignObject>
gSVG.g=<svg.g>
GoogleFontSVG.GoogleFont=<svg.GoogleFont>
imageSVG.image=<svg.image>
KiteSVG.Kite=<svg.Kite> SVG.Rhombuses
lineSVG.line=<svg.line>
linearGradientSVG.linearGradient=<svg.linearGradient>
LinePathSVG.LinePath=<SVG.LinedPath> =<svg.LinePath> SVG.LinedPath
markerSVG.marker=<svg.marker>
maskSVG.mask=<svg.mask>
metadataSVG.metadata=<svg.metadata>
mpathSVG.mpath=<svg.mpath>
pathSVG.path=<svg.path>
patternSVG.pattern=<svg.pattern>
polygonSVG.polygon=<svg.polygon>
polylineSVG.polyline=<svg.polyline>
radialGradientSVG.radialGradient=<svg.radialGradient>
rectSVG.rect=<svg.rect>
RhombusSVG.Rhombus=<svg.Rhombus> SVG.Rhombi
scriptSVG.script=<svg.script>
setSVG.set=<svg.set>
SpiralSVG.Spiral=<svg.Spiral>
StarSVG.Star=<svg.Star>
stopSVG.stop=<svg.stop>
styleSVG.style=<svg.style>
StyleSheetSVG.StyleSheet=<svg.StyleSheet>
svgSVG.svg=<svg> svg
switchSVG.switch=<svg.switch>
symbolSVG.symbol=<svg.symbol>
textSVG.text=<svg.text>
textPathSVG.textPath=<svg.textPath>
titleSVG.title=<svg.title>
TriangleSVG.Triangle=<svg.Triangle>
tspanSVG.tspan=<svg.tspan>
useSVG.use=<svg.use>
viewSVG.view=<svg.view>

(elements marked deprecated are not supported)

Goals

PSSVG hopes to be a useful toolkit for generating SVG images from PowerShell.

SVG has many benefits as an image file format, for example:

  • File Size
  • Scalability
  • Animations
  • Clickability
  • HTML/JavaScript/CSS integration
  • OS Integration

However, it is not a complete programming language.

Thus the primary goal is to make SVG creation scriptable.

Limitations

At current, PSSVG does not support aria attributes. Events can be generically specified with the parameter -On.

How PSSVG is Built

In order to provide an ideal PowerShell experience with rich help,
PSSVG is currently built by reading the contents of the Mozilla Developer Network's content repository.

It uses two PowerShell modules to read the repository and create the commands:

  • Irregular is used to help parse the markdown contents of the repository
  • PipeScript is used to create the functions from the parsed data.
github-actions
graphics
graphics-programming
powershell
svg
svg-animations
svg-icons
svg-images

StartAutomating/PSSVG

Script SVGs with PowerShell

PowerShell

45

29 commits

updated Aug 24, 2024

See the code

README

PowerShell tools for SVG.

PSSVG helps you create Scalable Vector Graphics using PowerShell.

There is a command for every tag of the SVG standard (and then some).

For example, this script generates the image below it.

svg (
    svg.text -X 50% -Y 50% -Fontsize 36 "Hello World" -DominantBaseline middle -TextAnchor middle -Fill '#4488ff'
) -ViewBox 0,0, 200, 100

PSSVG has a lot cooler Examples than hello world:

PSSVG is designed to act as a fairly complete domain specific language: every aspect of the SVG standard should be reflected in the commands of PSSVG.

The following commands are supported:

ElementFunctionAliases
aSVG.a=<svg.a>
animateSVG.animate=<svg.animate>
animateMotionSVG.animateMotion=<svg.animateMotion>
animateTransformSVG.animateTransform=<svg.animateTransform>
ANSISVG.ANSI=<svg.ANSI>
ArcPathSVG.ArcPath=<SVG.ArcedPath> =<svg.ArcPath> SVG.ArcedPath
circleSVG.circle=<svg.circle>
clipPathSVG.clipPath=<svg.clipPath>
ConvexPolygonSVG.ConvexPolygon=<svg.ConvexPolygon> SVG.Decagon SVG.Dodecagon SVG.Enneadecagon SVG.Hendecagon SVG.Heptadecagon SVG.Heptagon SVG.Hexadecagon SVG.Hexagon SVG.Icosagon SVG.Icosikaidigon SVG.Icosikaienneagon SVG.Icosikaihenagon SVG.Icosikaiheptagon SVG.Icosikaihexagon SVG.Icosikaioctagon SVG.Icosikaipentagon SVG.Icositetragon SVG.Icositrigon SVG.Nonagon SVG.Octadecagon SVG.Octagon SVG.Pentadecagon SVG.Pentagon SVG.Tetradecagon SVG.Triacontagon SVG.Tridecagon
CurvePathSVG.CurvePath=<SVG.CurvedPath> =<svg.CurvePath> SVG.CurvedPath
defsSVG.defs=<svg.defs>
descSVG.desc=<svg.desc>
discardSVG.discard=<svg.discard>
DropShadowSVG.DropShadow=<svg.DropShadow>
ellipseSVG.ellipse=<svg.ellipse>
feBlendSVG.feBlend=<svg.feBlend>
feColorMatrixSVG.feColorMatrix=<svg.feColorMatrix>
feComponentTransferSVG.feComponentTransfer=<svg.feComponentTransfer>
feCompositeSVG.feComposite=<svg.feComposite>
feConvolveMatrixSVG.feConvolveMatrix=<svg.feConvolveMatrix>
feDiffuseLightingSVG.feDiffuseLighting=<svg.feDiffuseLighting>
feDisplacementMapSVG.feDisplacementMap=<svg.feDisplacementMap>
feDistantLightSVG.feDistantLight=<svg.feDistantLight>
feDropShadowSVG.feDropShadow=<svg.feDropShadow>
feFloodSVG.feFlood=<svg.feFlood>
feFuncASVG.feFuncA=<svg.feFuncA>
feFuncBSVG.feFuncB=<svg.feFuncB>
feFuncGSVG.feFuncG=<svg.feFuncG>
feFuncRSVG.feFuncR=<svg.feFuncR>
feGaussianBlurSVG.feGaussianBlur=<svg.feGaussianBlur>
feImageSVG.feImage=<svg.feImage>
feMergeSVG.feMerge=<svg.feMerge>
feMergeNodeSVG.feMergeNode=<svg.feMergeNode>
feMorphologySVG.feMorphology=<svg.feMorphology>
feOffsetSVG.feOffset=<svg.feOffset>
fePointLightSVG.fePointLight=<svg.fePointLight>
feSpecularLightingSVG.feSpecularLighting=<svg.feSpecularLighting>
feSpotLightSVG.feSpotLight=<svg.feSpotLight>
feTileSVG.feTile=<svg.feTile>
feTurbulenceSVG.feTurbulence=<svg.feTurbulence>
filterSVG.filter=<svg.filter>
foreignObjectSVG.foreignObject=<svg.foreignObject>
gSVG.g=<svg.g>
GoogleFontSVG.GoogleFont=<svg.GoogleFont>
imageSVG.image=<svg.image>
KiteSVG.Kite=<svg.Kite> SVG.Rhombuses
lineSVG.line=<svg.line>
linearGradientSVG.linearGradient=<svg.linearGradient>
LinePathSVG.LinePath=<SVG.LinedPath> =<svg.LinePath> SVG.LinedPath
markerSVG.marker=<svg.marker>
maskSVG.mask=<svg.mask>
metadataSVG.metadata=<svg.metadata>
mpathSVG.mpath=<svg.mpath>
pathSVG.path=<svg.path>
patternSVG.pattern=<svg.pattern>
polygonSVG.polygon=<svg.polygon>
polylineSVG.polyline=<svg.polyline>
radialGradientSVG.radialGradient=<svg.radialGradient>
rectSVG.rect=<svg.rect>
RhombusSVG.Rhombus=<svg.Rhombus> SVG.Rhombi
scriptSVG.script=<svg.script>
setSVG.set=<svg.set>
SpiralSVG.Spiral=<svg.Spiral>
StarSVG.Star=<svg.Star>
stopSVG.stop=<svg.stop>
styleSVG.style=<svg.style>
StyleSheetSVG.StyleSheet=<svg.StyleSheet>
svgSVG.svg=<svg> svg
switchSVG.switch=<svg.switch>
symbolSVG.symbol=<svg.symbol>
textSVG.text=<svg.text>
textPathSVG.textPath=<svg.textPath>
titleSVG.title=<svg.title>
TriangleSVG.Triangle=<svg.Triangle>
tspanSVG.tspan=<svg.tspan>
useSVG.use=<svg.use>
viewSVG.view=<svg.view>

(elements marked deprecated are not supported)

Goals

PSSVG hopes to be a useful toolkit for generating SVG images from PowerShell.

SVG has many benefits as an image file format, for example:

  • File Size
  • Scalability
  • Animations
  • Clickability
  • HTML/JavaScript/CSS integration
  • OS Integration

However, it is not a complete programming language.

Thus the primary goal is to make SVG creation scriptable.

Limitations

At current, PSSVG does not support aria attributes. Events can be generically specified with the parameter -On.

How PSSVG is Built

In order to provide an ideal PowerShell experience with rich help,
PSSVG is currently built by reading the contents of the Mozilla Developer Network's content repository.

It uses two PowerShell modules to read the repository and create the commands:

  • Irregular is used to help parse the markdown contents of the repository
  • PipeScript is used to create the functions from the parsed data.
github-actions
graphics
graphics-programming
powershell
svg
svg-animations
svg-icons
svg-images

Project health

Overall

2.8/10

Maintained

0/10

Code review

0/10
OpenSSF Scorecard