Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ryan-leap/ShapeArray
Produces an array (with optional embedded text) which can be used for formatting console output
https://github.com/ryan-leap/ShapeArray
Last synced: 5 days ago
JSON representation
Produces an array (with optional embedded text) which can be used for formatting console output
- Host: GitHub
- URL: https://github.com/ryan-leap/ShapeArray
- Owner: ryan-leap
- License: mit
- Created: 2019-10-13T18:50:41.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-10-13T22:37:45.000Z (about 5 years ago)
- Last Synced: 2024-08-02T17:36:25.438Z (3 months ago)
- Language: PowerShell
- Homepage:
- Size: 12.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ShapeArray
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.## Installing
#### Download from GitHub repository* Download the repository from https://github.com/ryan-leap/ShapeArray
* Unblock the zip file ((on Windows) Right Click -> Properties -> [v/] Unblock)## Usage
```powershell
# Dot-source the file to bring the function in scope
. .\ShapeArray.ps1# Get help
Get-Help New-ShapeArrayGet-Help Join-Shape
```## Examples
### Produces an empty rectangle and rectangles with embedded text
```powershell
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! *
* *
*********************************************************************************************************
```
### Combines shape arrays into a single shape array
```powershell
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:\> $boxXXXXXXXXXX
XOOOOOOOOX
XOOOOOOOOX
XOOOOOOOOX
XXXXXXXXXXPS C:\> $boxes = $box
PS C:\> for ($i = 0; $i -lt 9; $i++) { $boxes = Join-Shape -Left $boxes -Right $box }
PS C:\> $boxesXXXXXXXXXX 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
```
## Author(s)* **Ryan Leap** - *Initial work*
## License
Licensed under the MIT License. See [LICENSE](LICENSE.md) file for details.