Creates an array whose arrangement of characters resembles a shape when displayed to the console. Specifically, New-ShapeRectangle
produces
a rectangularly shaped array which can optionally have embedded text justified to your needs. This is intended to be used for displaying nicely
formatted messages to the end-user of your tool/script.
- Download the repository from https://github.com/ryan-leap/ShapeArray
- Unblock the zip file ((on Windows) Right Click -> Properties -> [v/] Unblock)
# Dot-source the file to bring the function in scope
. .\ShapeArray.ps1
# Get help
Get-Help New-ShapeArray
Get-Help Join-Shape
PS C:\> New-ShapeRectangle -EdgeChar '-'
---------------------------------------------------------------------------------------------------------
- -
- -
- -
- -
---------------------------------------------------------------------------------------------------------
PS C:\> New-ShapeRectangle -TextEmbed "Hello World!"
*********************************************************************************************************
* *
* Hello World! *
* *
* *
*********************************************************************************************************
PS C:\> New-ShapeRectangle -Height 8 -TextEmbed 'Hello World!' -TextAlignHorizontal Left -TextAlignVertical Bottom
*********************************************************************************************************
* *
* *
* *
* *
* Hello World! *
* *
*********************************************************************************************************
PS C:\> $header = New-ShapeRectangle -Height 5 -TextEmbed "The Title"
PS C:\> $body = New-ShapeRectangle -Height 10 -EdgeChar ' ' -TextEmbed "The Content"
PS C:\> $footer = New-ShapeRectangle -Height 5 -TextEmbed "The End!"
PS C:\> $header; $body; $footer
*********************************************************************************************************
* *
* The Title *
* *
*********************************************************************************************************
The Content
*********************************************************************************************************
* *
* The End! *
* *
*********************************************************************************************************
PS C:\> Join-Shape -Left (New-ShapeRectangle -Width 20) -Right (New-ShapeRectangle -Width 50)
******************** **************************************************
* * * *
* * * *
* * * *
* * * *
******************** **************************************************
PS C:\> $box = New-ShapeRectangle -Height 5 -Width 10 -MarginLeft 0 -EdgeChar 'X' -FillChar 'O'
PS C:\> $box
XXXXXXXXXX
XOOOOOOOOX
XOOOOOOOOX
XOOOOOOOOX
XXXXXXXXXX
PS C:\> $boxes = $box
PS C:\> for ($i = 0; $i -lt 9; $i++) { $boxes = Join-Shape -Left $boxes -Right $box }
PS C:\> $boxes
XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX
XOOOOOOOOX XOOOOOOOOX XOOOOOOOOX XOOOOOOOOX XOOOOOOOOX XOOOOOOOOX XOOOOOOOOX XOOOOOOOOX XOOOOOOOOX XOOOOOOOOX
XOOOOOOOOX XOOOOOOOOX XOOOOOOOOX XOOOOOOOOX XOOOOOOOOX XOOOOOOOOX XOOOOOOOOX XOOOOOOOOX XOOOOOOOOX XOOOOOOOOX
XOOOOOOOOX XOOOOOOOOX XOOOOOOOOX XOOOOOOOOX XOOOOOOOOX XOOOOOOOOX XOOOOOOOOX XOOOOOOOOX XOOOOOOOOX XOOOOOOOOX
XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX
- Ryan Leap - Initial work
Licensed under the MIT License. See LICENSE file for details.