Scroll to navigation

palcomp(1) hxtools palcomp(1)

Name

palcomp — palette composer

Syntax

palcomp [commands...]

Description

palcomp can be used to generate palettes for terminals. The most important realization is that programs running within a terminal and which use console_codes(4) to set colors rely on the contrast of the colors produced by a color pairing to be proportional to the contrast those two codes have when using the VGA color palette. For this reason, a mainstay of this program is to operate using a colorspace with perceptual uniformity, i.e. CIELAB/LCh.

Commands

b0

Set color 0 to actual black. (This is done for both the LCh and RGB in-memory palettes, so that it does not matter whether "b0" is issued before or after a "rgb" command.)

bg

Emit a -bg parameter upon xterm, and use color 0.

ct

Print the 16-color table.

ct256

Print 256-color cubes and tables.

cxl

Print a contrast analysis of the palette based on brightness differences.

cxr

Print a contrast analysis of the palette based on radiosity differences. This is useful because even if two colors have the same/a similar brightness in the LCh colorspace, it is possible for (sufficiently capable) humans to distinguish such two colors.

debug

Turn on individual colorspace conversion reporting.

emit

Emit the palette as a line for an XDG theme file.

stat

Emit the LCh form of the palette to stdout (no particular formatting).

fg

Emit a -fg parameter upon xterm, and use color 7.

hueadd=h

Rotate colors using LCh space. (0 <= h < 360)

hueset=h

Set the hue of all colors using LCh space.

inv16

Perform color inversion the way Norton Icon Editor did it.

litadd=r

Change colors' brightness using LCh space.

litmul=r

Multiply colors' brightness using LCh space.

litset=r

Set colors' brightness using LCh space.

satadd=r

Change colors' saturation using LCh space.

satmul=r

Multiply colors' saturation using LCh space. In effect, with r<1, this causes a desaturation of colors; r=0 leads to gray.

satset=r

Set colors' saturation using LCh space.

hsltint=h,s,l

Map the (LCh) brightnesses onto a color line through the HSL cylinder that goes from black to the chosen color. Parameter ranges are (0 <= h < 360; 0 <= s < 1; 0 <= l <= 1). The result of the operation is stored in the RGB palette. When using s<=0.5, this produces a black-to-{color} ramp; when using s==1, this produces a black-to-{color}-to-white ramp.

hsltint produces a somewhat more contrasty result than manipulating hue and saturation in LCh. Compare:

  • palcomp vgs lch satset=100 hueset=120 rgb emit
  • palcomp vgs lch hsltint=90,1,0.5 emit

hsltint=#rrggbb[,l]

A different syntax for the hsltint operation. First, the RGB value for the tint color is converted to HSL. The so-computed L value can be overridden with the optional ,l suffix. Afterwards, behaves like hsltint=h,s,l.

lchtint=h,s,l

lchtint=#rrggbb[,l]

Replace the LCh hue and saturation by the base color given in HSL or RGB. The LCh L value is retained as-is.

loeq=b,g

Equalize (equal-space) the brightnesses of the palette's low-intensity colors plus darkgray. The b parameter (0 <= b <= g) specifies the mandatory offset from the darkest to 2nd darkest color — often this is black to blue. The g parameter (b <= g <= 100) specifies the lightness that gray is to use. If g is absent, uses g=8/9. If b is absent, uses b=1/9.

vga

Loads the standard VGA palette.

vgs

Loads a full-saturated VGA palette.

win

Loads the standard Windows palette.

xterm

Emit the RGB palette as xterm command line options. Use e.g. `xterm $(palcomp vga hueset=120 xterm)` to utilize.

Examples

Amber tint via LCh color space:

palcomp vgs lchtint=#95ef1d b0 emit

Black-to-green ramp (tint via HSL color space):

  • palcomp vgs hsltint=120,1,0.5 emit
  • palcomp vgs hsltint=#00ff00 emit

Black-to-green-white ramp (tint via HSL color space):

  • palcomp vgs hsltint=120,1,1 emit
  • palcomp vgs hsltint=#00ff00,1 emit

Caveats

Lightness in LCh space behaves a bit counterintuitive. When (saturation) c>0, then L=0 does not mean black; black is attained in the negative range (and it depends on the saturation/hue). As a consequence, one needs to manipulate (shift and stretch) the L channel values more, e.g. after a tint. Consider the following chain of commands to create some blue tints, and have that tint actually reach black:

  • palcomp vgs lchtint=#0000ff litadd=-42 litmul=1.74 stat emit
  • palcomp vgs lchtint=#0080ff litadd=-25 litmul=1.49 stat emit

Stretching the brightness this way has the side-effect that all colors get a bit darker, which may be undesirable. Instead of combining a tint with litadd and litmul, I can recommend to force color 0 to black using the b0 command.

See also

hxtools(7)

2022-10-23 hxtools