Skip to content

Commit

Permalink
Assume 16 colors mean VGA palette
Browse files Browse the repository at this point in the history
I can't see any other reason for telling moar to use 16 colors than if
your hardware actually can't do more. And that means VGA.
  • Loading branch information
walles committed Oct 5, 2024
1 parent c42ac5f commit 3a4c54e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
30 changes: 15 additions & 15 deletions twin/palette256.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@ func color256ToRGB(color256 uint8) (r, g, b uint8) {
return r, g, b
}

// Source, the 256 colors table from here:
// Source, the VGA color palette from here:
// https://en.wikipedia.org/wiki/ANSI_escape_code#3-bit_and_4-bit
var standardAnsiColors = [16][3]uint8{
{0x00, 0x00, 0x00}, // Black
{0x80, 0x00, 0x00}, // Red
{0x00, 0x80, 0x00}, // Green
{0x80, 0x80, 0x00}, // Yellow
{0x00, 0x00, 0x80}, // Blue
{0x80, 0x00, 0x80}, // Magenta
{0x00, 0x80, 0x80}, // Cyan
{0x80, 0x80, 0x80}, // White
{0xAA, 0x00, 0x00}, // Red
{0x00, 0xAA, 0x00}, // Green
{0xAA, 0x55, 0x00}, // Yellow
{0x00, 0x00, 0xAA}, // Blue
{0xAA, 0x00, 0xAA}, // Magenta
{0x00, 0xAA, 0xAA}, // Cyan
{0xAA, 0xAA, 0xAA}, // White

{0x80, 0x80, 0x80}, // Bright Black
{0xff, 0x00, 0x00}, // Bright Red
{0x00, 0xff, 0x00}, // Bright Green
{0xff, 0xff, 0x00}, // Bright Yellow
{0x00, 0x00, 0xff}, // Bright Blue
{0xff, 0x00, 0xff}, // Bright Magenta
{0x00, 0xff, 0xff}, // Bright Cyan
{0x55, 0x55, 0x55}, // Bright Black
{0xff, 0x55, 0x55}, // Bright Red
{0x55, 0xff, 0x55}, // Bright Green
{0xff, 0xff, 0x55}, // Bright Yellow
{0x55, 0x55, 0xff}, // Bright Blue
{0xff, 0x55, 0xff}, // Bright Magenta
{0x55, 0xff, 0xff}, // Bright Cyan
{0xff, 0xff, 0xff}, // Bright White
}
4 changes: 2 additions & 2 deletions twin/palette256_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
func TestColorRgbFirst16(t *testing.T) {
r, g, b := color256ToRGB(5)

assert.Equal(t, r, uint8(0x80))
assert.Equal(t, r, uint8(0xaa))
assert.Equal(t, g, uint8(0x00))
assert.Equal(t, b, uint8(0x80))
assert.Equal(t, b, uint8(0xaa))
}

func TestColorToRgbInTheGrey(t *testing.T) {
Expand Down

0 comments on commit 3a4c54e

Please sign in to comment.