Skip to content

Commit

Permalink
fix(ansi): color: only return the first three bytes of the hex value
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Jan 12, 2025
1 parent 9d5df1d commit 1775be7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ansi/color.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func ansiToRGB(ansi uint32) (uint32, uint32, uint32) {
//
// r, g, b := hexToRGB(0x0000FF)
func hexToRGB(hex uint32) (uint32, uint32, uint32) {
return hex >> 16, hex >> 8 & 0xff, hex & 0xff
return hex >> 16 & 0xff, hex >> 8 & 0xff, hex & 0xff
}

// toRGBA converts an RGB 8-bit color values to 32-bit color values suitable
Expand Down
2 changes: 1 addition & 1 deletion ansi/color_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func TestRGBAToHex(t *testing.T) {
}{
{0, 0, 255, 0xffff, 0x0000ff},
{255, 255, 255, 0xffff, 0xffffff},
{255, 0, 0, 0xffff, 0xff0000},
{255, 0, 0, 0xffff, 0xffff0000},
}

for _, c := range cases {
Expand Down

0 comments on commit 1775be7

Please sign in to comment.