Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/core/src/style/Color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,10 @@ function rgbToAnsi256(r: number, g: number, b: number): number {
if (grayIdx < 0) grayIdx = 0;
if (grayIdx > 23) grayIdx = 23;
const grayColor = 232 + grayIdx;
r_c = ANSI256_RGB[grayColor * 3];
const distGray = (r - r_c)**2 + (g - r_c)**2 + (b - r_c)**2;
const r_gray = ANSI256_RGB[grayColor * 3];
const g_gray = ANSI256_RGB[grayColor * 3 + 1];
const b_gray = ANSI256_RGB[grayColor * 3 + 2];
const distGray = (r - r_gray)**2 + (g - g_gray)**2 + (b - b_gray)**2;
if (distGray < bestDist) {
bestDist = distGray;
bestColor = grayColor;
Expand Down
Loading