eugene-eeo / orchid

very tiny music player
MIT License
152 stars 7 forks source link

256 colour terminal support #2

Open jai-x opened 6 years ago

jai-x commented 6 years ago

This music player is really cool, although I am missing out on the album art feature due to not having a true colour terminal available.

Could there be an option such that the colours used in the album art display be approximated to within the 256 colour range?

eugene-eeo commented 6 years ago

Hi, I'll give it a go when I'm free. Although your best bet if you really want to use it (and know some Go) is to look into ansimage/ansimage.go and manually tweak it so that you approximate the true RGB values. I won't be changing this file much, so it is safe (for the foreseeable future) to mess about with it in your fork. Line 88 is where you should modify:

// Render returns the ANSI-compatible string form of ANSI-pixel.
func (ap *ANSIpixel) Render() string {
    if ap.upper {
        return fmt.Sprintf(
            "\033[48;2;%d;%d;%dm",
            ap.R, ap.G, ap.B,
        )
    }
    return fmt.Sprintf(
        "\033[38;2;%d;%d;%dm%s",
        ap.R, ap.G, ap.B,
        lowerHalfBlock,
    )
}

PS: In the future I might port orchid to use gdamore/tcell to avoid hacking around termbox so I will change the file, but I don't really have a hard deadline on when I'll do that, if ever.