Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pastel pick doesn't display all colors #121

Closed
nycex opened this issue Apr 5, 2020 · 8 comments · Fixed by #168
Closed

pastel pick doesn't display all colors #121

nycex opened this issue Apr 5, 2020 · 8 comments · Fixed by #168
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@nycex
Copy link

nycex commented Apr 5, 2020

When I run pastel pick in st or urxvt, i get a output like output_image
even though when running this:

awk 'BEGIN{
    s="/\\/\\/\\/\\/\\"; s=s s s s s s s s;
    for (colnum = 0; colnum<77; colnum++) {
        r = 255-(colnum*255/76);
        g = (colnum*510/76);
        b = (colnum*255/76);
        if (g>255) g = 510-g;
        printf "\033[48;2;%d;%d;%dm", r,g,b;
        printf "\033[38;2;%d;%d;%dm", 255-r,255-g,255-b;
        printf "%s\033[0m", substr(s,colnum+1,1);
    }
    printf "\n";
}'

from https://gist.github.com/XVilka/8346728, I get a smooth gradient:
gradient_image
In alacritty, it seems to work though:
alacritty_output_image

@sharkdp
Copy link
Owner

sharkdp commented Apr 5, 2020

It appears that urxvt does not set the COLORTERM variable to truecolor, which is the only way how we can detect that a terminal emulator supports 24bit colors.

If you run pastel colorcheck, you should be able to clearly determine whether or 24bit is supported.

@sharkdp
Copy link
Owner

sharkdp commented Apr 5, 2020

Don't you see a warning in the top output of pastel pick?

image

@nycex
Copy link
Author

nycex commented Apr 5, 2020

Well, I saw the warning and set the environment variable PASTEL_COLOR_MODE=24bit. With this enabled, I get the output in st and urxvt I showed earlier. But now that I tried, when I set COLORTERM=24bit or COLORTERM=truecolor, then it shows correctly all the colors like in alacritty. Maybe there is a problem with the check for PASTEL_COLOR_MODE

Edit: Btw it just works for st, I just looked into it and urxvt doesn't even support truecolor to my surprise.

@sharkdp
Copy link
Owner

sharkdp commented Apr 5, 2020

Maybe there is a problem with the check for PASTEL_COLOR_MODE

It looks like there is, yes. I can reproduce it. Thank you for reporting this!

(Unrelated: in general, I suggest using a terminal which properly sets COLORTERM. This will also enable true color support in many other programs).

@sharkdp sharkdp added the bug Something isn't working label Apr 5, 2020
@sharkdp sharkdp added the good first issue Good for newcomers label May 25, 2020
@yugonline
Copy link

Can you explain where to start? I can give this a go but I'm new to Rust. So I'll timebox it to not waste time.

@sharkdp
Copy link
Owner

sharkdp commented May 9, 2021

@yugonline Sorry for the delay. Are you still interested in tackling this?

@sharkdp
Copy link
Owner

sharkdp commented May 9, 2021

So to reproduce this, run:

COLORTERM="" PASTEL_COLOR_MODE=24bit pastel pick

It should show a smooth color palette (like for COLORTERM="truecolor" pastel pick), and not with a restricted color depth, like in the screenshot above.

Next, look into src/cli/colorpicker.rs and start here:

    let mut canvas = Canvas::new(
        width + 2 * config.padding,
        width + 2 * config.padding,
        Brush::from_environment(Stream::Stderr),
    );

The problem is the Brush::from_environment(Stream::Stderr) call which detects colordepth support by checking whether STDERR is an interactive terminal or not. Instead, it should also take into account environment variables. Search for COLORTERM and PASTEL_COLOR_MODE, to see how it is used in other places.

@yugonline
Copy link

Sounds good I'll take a look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants