Skip to content

Add ansi256 → ansi16 - #93

Open
Richienb wants to merge 3 commits into
Qix-:masterfrom
Richienb:add-ansi256-to-ansi16
Open

Richienb wants to merge 3 commits into
Qix-:masterfrom
Richienb:add-ansi256-to-ansi16

Conversation

@Richienb

@Richienb Richienb commented Apr 21, 2021 •

Copy link
Copy Markdown

Output in Windows Terminal:

Grid of colours with an ansi256 code and a corresponding ansi16 code

Fixes #92, Fixes #89

Signed-off-by: Richie Bendall <richiebendall@gmail.com>
Signed-off-by: Richie Bendall <richiebendall@gmail.com>
@Qix-

Qix- commented Apr 21, 2021

Copy link
Copy Markdown
Owner

Thanks - could you add tests that check the result of ansi256.ansi16() to rgb.ansi16(ansi256.rgb()) to make sure it's as expected?

Something like:

for (let i = 0; i < 8; i++) {
    assert( cc.ansi256.ansi16(i) === (i + 30) );
}

for (let i = 8; i < 16; i++) {
    assert( cc.ansi256.ansi16(i) === (i + 90) );
}

for (let i = 16; i < 256; i++) {
    assert( cc.ansi256.ansi16(i) === cc.rgb.ansi16(cc.ansi256.rgb(i)) );
}

Signed-off-by: Richie Bendall <richiebendall@gmail.com>
@Richienb

Copy link
Copy Markdown
Author

Couldn't get the third test to work but the other 2 passed fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ansi256->ansi16 short circuit ansi256 => ansi16 squashes a bunch of grayscale values and basic colors to black

2 participants