💻 TermColor User Manual
Classes | Public Member Functions | Static Public Attributes | Package Functions | Properties | List of all members
TermColor.DitherMapping Class Reference
Collaboration diagram for TermColor.DitherMapping:
Collaboration graph
[legend]

Classes

struct  ColoredChar
 

Public Member Functions

 DitherMapping (IEnumerable< KeyValuePair< char, float >> configuration)
 
ColoredChar Map (in ColorRGB color)
 
void Precompute (int resolution=6)
 

Static Public Attributes

static readonly DitherMapping Default
 

Package Functions

ColorRGB Mix (ColorRGB foreground, ColorRGB background, char mask)
 
ColoredChar FindClosest (in ColorRGB color)
 

Properties

IReadOnlyDictionary< char, float > MaskOpacity [get]
 
bool IsComputed [get]
 
int? Resolution [get]
 

Detailed Description

Represents a dithering character set with precomputed palette.

This class can find closest approximation of a given color by mixing different colors and masking characters. It precomputes this approximation to a certain level of detail (see Precompute(int)) and can later find color aproximations (see Map(in ColorRGB)).

Constructor & Destructor Documentation

◆ DitherMapping()

TermColor.DitherMapping.DitherMapping ( IEnumerable< KeyValuePair< char, float >>  configuration)
inline

Create a dithering character set.

Parameters
configurationList of dithering characters with their respective opacities. See Default for an example value.

Member Function Documentation

◆ FindClosest()

ColoredChar TermColor.DitherMapping.FindClosest ( in ColorRGB  color)
inlinepackage

Search the entire color space and find the closest approximation of color .

Parameters
color
Returns

◆ Map()

ColoredChar TermColor.DitherMapping.Map ( in ColorRGB  color)
inline

Find best approximation of color using the precomputed data.

Exceptions
InvalidOperationExceptionThrown when not precomputed.
Parameters
colorThe color to approximate
Returns

◆ Mix()

ColorRGB TermColor.DitherMapping.Mix ( ColorRGB  foreground,
ColorRGB  background,
char  mask 
)
inlinepackage

Mix two colors using the specified character.

Parameters
foregroundForeground color.
backgroundBackground color.
maskThe mask character.
Returns
The perceived color when the mask character is printed on screen with given colors.

◆ Precompute()

void TermColor.DitherMapping.Precompute ( int  resolution = 6)
inline

Precompute the color mapping approximation.

Parameters
resolution

Member Data Documentation

◆ Default

readonly DitherMapping TermColor.DitherMapping.Default
static
Initial value:
= new DitherMapping(new KeyValuePair<char, float>[] {
new ( ' ', 0 / 4f ),
new ( 'â–‘', 1 / 4f ),
new ( 'â–’', 2 / 4f ),
new ( 'â–“', 3 / 4f ),
})
DitherMapping(IEnumerable< KeyValuePair< char, float >> configuration)
Create a dithering character set.
Definition: DitherMapping.cs:81

The default dithering preset with the following configuration:


{ new ( ' ', 0 / 4f ), new ( 'â–‘', 1 / 4f ), new ( 'â–’', 2 / 4f ), new ( 'â–“', 3 / 4f ) }

Property Documentation

◆ IsComputed

bool TermColor.DitherMapping.IsComputed
get

True if the preset has already been precomputed.

◆ MaskOpacity

IReadOnlyDictionary<char, float> TermColor.DitherMapping.MaskOpacity
get

Configuration of this preset. List of dithering characters with their respective opacities.

◆ Resolution

int? TermColor.DitherMapping.Resolution
get

Resolution of the approximation.


The documentation for this class was generated from the following file: