Skip to content

Commit 1fc2e75

Browse files
committed
Update docs
1 parent e1dce19 commit 1fc2e75

7 files changed

+209
-22
lines changed

Docs/Convert-ConsolePalette.md

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
---
2+
external help file: Pansies-help.xml
3+
online version:
4+
schema: 2.0.0
5+
---
6+
7+
# Convert-ConsolePalette
8+
9+
## SYNOPSIS
10+
Converts the current 16 Color console palette by shifting either the dark or light colors to darker or lighter shades.
11+
12+
## SYNTAX
13+
14+
### Dark (Default)
15+
```
16+
Convert-ConsolePalette [-DarkShift] <Int32> [-Copy] [-WhatIf] [-Confirm]
17+
```
18+
19+
### Bright
20+
```
21+
Convert-ConsolePalette -BrightShift <Int32> [-Copy] [-WhatIf] [-Confirm]
22+
```
23+
24+
## DESCRIPTION
25+
Converts a 16 Color console palette by shifting either the dark or light colors to darker or lighter shades.
26+
27+
## EXAMPLES
28+
29+
### Example 1
30+
```
31+
PS C:\> Convert-ConsolePalette -BrightShift 20 -Copy
32+
```
33+
34+
Copies the Dark* colors from the console palette to the bright side and brightens them by 20 (of 100) luminance.
35+
36+
## PARAMETERS
37+
38+
### -BrightShift
39+
How much to shift the bright colors. Positive values make the colors brighter, negative values make them darker
40+
41+
```yaml
42+
Type: Int32
43+
Parameter Sets: Bright
44+
Aliases:
45+
46+
Required: True
47+
Position: Named
48+
Default value: None
49+
Accept pipeline input: False
50+
Accept wildcard characters: False
51+
```
52+
53+
### -Confirm
54+
Prompts you for confirmation before running the cmdlet.
55+
56+
```yaml
57+
Type: SwitchParameter
58+
Parameter Sets: (All)
59+
Aliases: cf
60+
61+
Required: False
62+
Position: Named
63+
Default value: None
64+
Accept pipeline input: False
65+
Accept wildcard characters: False
66+
```
67+
68+
### -Copy
69+
By default, the colors are modified in-place. If copy is set:
70+
- the dark colors start with the value of the bright colors
71+
- the light colors start at the value of the dark colors
72+
73+
```yaml
74+
Type: SwitchParameter
75+
Parameter Sets: (All)
76+
Aliases:
77+
78+
Required: False
79+
Position: Named
80+
Default value: None
81+
Accept pipeline input: False
82+
Accept wildcard characters: False
83+
```
84+
85+
### -DarkShift
86+
How much to shift the dark colors. Positive values make the colors brighter, negative values make them darker
87+
88+
```yaml
89+
Type: Int32
90+
Parameter Sets: Dark
91+
Aliases:
92+
93+
Required: True
94+
Position: 0
95+
Default value: None
96+
Accept pipeline input: False
97+
Accept wildcard characters: False
98+
```
99+
100+
### -WhatIf
101+
Shows what would happen if the cmdlet runs.
102+
The cmdlet is not run.
103+
104+
```yaml
105+
Type: SwitchParameter
106+
Parameter Sets: (All)
107+
Aliases: wi
108+
109+
Required: False
110+
Position: Named
111+
Default value: None
112+
Accept pipeline input: False
113+
Accept wildcard characters: False
114+
```
115+
116+
## INPUTS
117+
118+
### None
119+
120+
121+
## OUTPUTS
122+
123+
### System.Object
124+
125+
## NOTES
126+
127+
## RELATED LINKS
128+

Docs/Get-Complement.md

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
external help file: Pansies-help.xml
3-
online version:
3+
Module Name: Pansies
4+
online version:
45
schema: 2.0.0
56
---
67

@@ -57,7 +58,7 @@ The source color to calculate the complement of
5758
```yaml
5859
Type: RgbColor
5960
Parameter Sets: (All)
60-
Aliases:
61+
Aliases:
6162

6263
Required: True
6364
Position: 1
@@ -67,13 +68,12 @@ Accept wildcard characters: False
6768
```
6869
6970
### -ForceContrast
70-
7171
Force the luminance to have "enough" contrast
7272
7373
```yaml
7474
Type: SwitchParameter
7575
Parameter Sets: (All)
76-
Aliases:
76+
Aliases:
7777

7878
Required: False
7979
Position: Named
@@ -83,13 +83,12 @@ Accept wildcard characters: False
8383
```
8484
8585
### -ConsoleColor
86-
8786
Assume there are only 16 colors. Return either black or white to get a readable contrast color.
8887
8988
```yaml
9089
Type: SwitchParameter
9190
Parameter Sets: (All)
92-
Aliases:
91+
Aliases:
9392

9493
Required: False
9594
Position: Named
@@ -105,7 +104,7 @@ If set, output the input $Color before the complement
105104
```yaml
106105
Type: SwitchParameter
107106
Parameter Sets: (All)
108-
Aliases:
107+
Aliases:
109108

110109
Required: False
111110
Position: Named

Docs/Get-Gradient.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
external help file: Pansies-help.xml
3-
online version:
3+
Module Name: Pansies
4+
online version:
45
schema: 2.0.0
56
---
67

@@ -44,13 +45,12 @@ Gets a 2D gradient from the ConsoleColor Red to Blue, with the width x height th
4445
## PARAMETERS
4546

4647
### -StartColor
47-
4848
The left color to start the gradient from.
4949

5050
```yaml
5151
Type: RgbColor
5252
Parameter Sets: (All)
53-
Aliases:
53+
Aliases:
5454

5555
Required: True
5656
Position: 1
@@ -67,7 +67,7 @@ The right color to end the gradient at.
6767
```yaml
6868
Type: RgbColor
6969
Parameter Sets: (All)
70-
Aliases:
70+
Aliases:
7171

7272
Required: True
7373
Position: 2
@@ -97,7 +97,7 @@ The number of rows to generate in the gradient. Defaults to 1
9797
```yaml
9898
Type: Int32
9999
Parameter Sets: (All)
100-
Aliases:
100+
Aliases:
101101

102102
Required: False
103103
Position: 4
@@ -113,7 +113,7 @@ CMY, CMYK, LAB, LCH, LUV, HunterLAB, HSL, HSV, HSB, RGB, XYZ, YXY
113113
```yaml
114114
Type: Object
115115
Parameter Sets: (All)
116-
Aliases:
116+
Aliases:
117117

118118
Required: False
119119
Position: Named
@@ -128,7 +128,7 @@ For color spaces with Hue (HSL, HSV, HSB), setting this generates the gradient t
128128
```yaml
129129
Type: SwitchParameter
130130
Parameter Sets: (All)
131-
Aliases:
131+
Aliases:
132132

133133
Required: False
134134
Position: Named
@@ -143,7 +143,7 @@ Flattens the 2D array to a single array.
143143
```yaml
144144
Type: SwitchParameter
145145
Parameter Sets: (All)
146-
Aliases:
146+
Aliases:
147147

148148
Required: False
149149
Position: Named

Docs/New-Text.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,20 @@ and by default, outputs escape sequences to clear those colors after the text.
2525
### Example 1
2626
```
2727
PS C:\> New-Text "&hearts;" -ForegroundColor Red
28+
29+
30+
BackgroundColor ForegroundColor Object ToString
31+
--------------- --------------- ------ --------
32+
`e[101m `e[0m Red &hearts;`e[0m `e[91m?`e[39m`e[0m
2833
```
2934

3035
Generates a text object with the hearts symbol (♥) in red. The output will show the BackgroundColor, ForegroundColor, Text (with the entity text in it) and the rendered output of `.ToString()` where the entity will be replaced with the hearts symbol.
3136

3237
### Example 1
3338
```
34-
PS C:\> "I $(New-Text "&hearts;" -ForegroundColor Red) PS"
39+
PS C:\> "I $(New-Text "&hearts;" -ForegroundColor "#F00") PS"
40+
41+
I `e[38;2;255;0;0m?`e[39m PS
3542
```
3643

3744
Outputs the text "I ♥ PS" with the heart in red.

Docs/Pansies.md

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
Module Name: Pansies
3+
Module Guid: 6c376de1-1baf-4d52-9666-d46f6933bc16
4+
Download Help Link: {{Please enter FwLink manually}}
5+
Help Version: {{2.0}}
6+
Locale: en-US
7+
---
8+
9+
# <strong>P</strong>owershell <strong>ANSI E</strong>scape <strong>S</strong>equences Module
10+
11+
## Description
12+
This module contains classes and functions for doing ANSI colored output using Virtual Terminal escape sequences in the console from .Net and PowerShell on platforms where they are supported: Windows 10, Linux, OS X, etc.
13+
14+
It also contains commands for manipulating the Windows console color palette and converting color settings from iTerm and VSCode, including a "theme" format based on psd1 files.
15+
16+
It requires PowerShell 5 or higher, and an ANSI-capable host like the Windows 10 console, or xTerm, iTerm, or ConEmu.
17+
18+
## Cmdlets
19+
20+
### [Get-Complement](Get-Complement.md)
21+
Get the Hue complement color
22+
23+
### [Get-Gradient](Get-Gradient.md)
24+
Get a range of colors between two colors
25+
26+
### [New-Text](New-Text.md)
27+
Create a Text object with specified background and foreground colors. Supports [HTML named entities](https://www.w3schools.com/charsets/ref_html_entities_4.asp) like `&hearts;` and `&frac12;` or `&uuml;` and numerical unicode character entities in both decimal (e.g. `&#926;`) and hexadeximal (`&#x39E;`)
28+
29+
### [Write-Host](Write-Host.md)
30+
Backwards compatible Write-Host replacement which writes customized output to a host, but using full RGB color values.
31+
32+
## Providers
33+
34+
Pansies provides an RgbColor provider, with two default drives: Fg, and Bg. These are "content" drives which provide a way for you to refer to any color as though it were a variable, like: `${fg:red}` or `${fg:#FF0000}` and even `${fg:clear}` so you can change colors in the middle of a string:
35+
36+
```
37+
C:\PS> "I ${fg:red}♥${fg:clear} PS"
38+
```
39+
40+
## Classes
41+
42+
Pansies provides a few important classes:
43+
44+
*RgbColor* is a powerful representation of RGB colors with support for parsing CSS style color strings "#RRGGBB" and XTerm indexes, as well as handling the ConsoleColor values PowerShell users are used to. In addition to that, it has conversions to other color spaces for the purpose of doing color math like generating palettes and gradients, etc. The `ToString()` implementation shows the properties, but there is an overload which takes a boolean for Background or Foreground and renders to ANSI escape sequences. It has built-in palette for XTerm, and a built-in ConsoleColor palette which (on Windows) sniffs the current console's current color configuration. It uses these palettes to automatically downsample RGB colors to the nearest match when it's necessary to render in those color spaces.
45+
46+
*Text* is a text class which contains BackgroundColor and ForegroundColor properties and a `ToString()` implementation based on VT escape sequences. It also supports HTML named enties like the `&hearts;` example above.
47+
48+
There are also *Palette* classes which support the XTerm 256 color palette, the X11 named colors palette (with over 650 named colors), and the default 16 color console palette (which includes loading the actual palette of the console in Windows). Each of these Palettes has the ability to find the closest match to any given RgbColor.
49+
50+
You can play with setting `[PoshCode.Pansies.RgbColor]::ColorMode` to change how the colors are down-sampled, and modify the actual palettes in `[PoshCode.Pansies.RgbColor]::ConsolePalette` and `[PoshCode.Pansies.RgbColor]::XTermPalette`
51+
52+
53+
## Contribute
54+
55+
The end goal for this project is for the Color and Text classes (possibly without the color space conversions) to make it into the core PowerShell product, so what I'm most interested in here is [any ideas](https://github.com/PoshCode/Pansies/issues) people have for a better user experience for writing text and partially colored text, as well as other ANSI Virtual Terminal escape sequences.
56+
57+
For the sake of PowerShell 5, I intend to keep this module around. Any features that don't belong in PowerShell core will stay here too, and I may even split some of the Windows-specific features into a `PANSIES.Windows` module or something, to support themes on older versions of PowerShell for Windows (running in ConEmu with ANSI support, or just downsampling everything to ConsoleColors).

Source/Public/Get-Complement.ps1

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
function Get-Complement {
2-
<#
3-
.EXTERNALHELP Pansies-help.xml
4-
#>
2+
# .EXTERNALHELP Pansies-help.xml
53
[CmdletBinding()]
64
[OutputType([PoshCode.Pansies.RgbColor])]
75
param(

Source/Public/Get-Gradient.ps1

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
function Get-Gradient {
2-
<#
3-
.EXTERNALHELP Pansies-help.xml
4-
#>
2+
# .EXTERNALHELP Pansies-help.xml
53
[CmdletBinding()]
64
[OutputType([PoshCode.Pansies.RgbColor[][]],[PoshCode.Pansies.RgbColor[]])]
75
param(

0 commit comments

Comments
 (0)