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

sRGB color space issue #50

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

sRGB color space issue #50

wants to merge 2 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Jun 7, 2018

See gnachman/iTerm2#149

iTerm2 by default interprets the floats in the iTerm2 colorscheme as 'Generic RGB Profile' instead of sRGB. It then converts them to sRGB in it's profile.

Image of ColorSync

This means the intended background color of #3A3A3A is displayed as #4B4B4B in iTerm2. This is incorrect and it means seoul256 theme is displayed far brighter than needed.

The solution is to explicitly tell iTerm2 that the colors specified in the profile are sRGB (proof: 0.22745098039215686 * 255 = 58, which is equal to the urxvt color scheme).

Actually on a different note, the seoul256_srgb map only applies to gui vim, and funnily enough on the normal iTerm2 command line vim, the colors are correctly set to the srgb values regardless (i.e. the background is properly set to #3A3A3A).

But if you open MacVim/gvim on without setting let g:seoul256_srgb = 1 then gvim is too bright, seeing the background to #4B4B4B

Image of gvim

Something else to do would be to remove the seoul256_srgb setting to fix gui vim from displaying super bright colors.

ALTERNATIVE INTERPRETATION: The iTerm2 colors are correct - which means the colors used for urxvt and vim are wrong, in which case another PR should be raised to fix everything else.

@ghost ghost mentioned this pull request Jun 7, 2018
\ 250: '#bcbcbc', 251: '#c6c6c6', 252: '#d0d0d0',
\ 253: '#dadada', 254: '#e4e4e4', 255: '#eeeeee' }
else
let s:rgb_map =
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funnily enough, if you take ALL of these values, convert each value into a float, interpret it as "Generic RGB", convert it to sRGB and back to hex, you get the colors in the table above.

@junegunn
Copy link
Owner

junegunn commented Jun 7, 2018

seoul256 theme is displayed far brighter than needed

Thanks, but actually that is the color palette I originally intended. Gauge the background color of the screenshot on the README page. The screenshot was taken a few years ago, pre iTerm 3.0 era, and if I recall correctly, iTerm started to render those ANSI colors darker than I intended since 3.0, but I didn't adjust the color scheme for users who were still using iTerm 2.0. Now, Vim and iTerm2 support 24-bit colors and you can see the same brightness on terminal Vim with set termguicolors.

Please let me know if you see any inconsistencies.

@ghost
Copy link
Author

ghost commented Jun 7, 2018

Hey @junegunn

Huge fan of the theme. I wasn't sure which color scheme was the correct one, thanks for clarifying.

That means this PR is incorrect, feel free to close it.

Linux users can also set termguicolors if they don't apply let g:seoul256_srgb = 1 to get the "brighter" theme. The urxvt color scheme is also using the "darker" color scheme. Should we update the README and the Urxvt/Xresources/etc config files?

@ghost
Copy link
Author

ghost commented Jun 7, 2018

Actually it looks like all the other color schemes (KDE) also uses Color=58,58,58 for the background instead of 75,75,75 (and various other colors are all the "dark" variants). Intended?

@junegunn
Copy link
Owner

junegunn commented Jun 7, 2018

Intended?

Probably not. I'm just a Mac user and I think I accepted those pull requests without actually trying them out.

@randrej
Copy link
Contributor

randrej commented Mar 22, 2020

@junegunn I want to fix this once an for all? Can you please run this script in the same environment like you had when you posted the screenshots, and screenshot all the lines? I want to recreate the colors in your screenshots in Linux, and I need bigger fields (or non-anti-aliased text) to do so. This script just prints all of the colors used in seoul256, both RGB and ANSI to the terminal.

If your current terminal displays 24bit (RGB) colors properly, this should be enough.

I tried doing color conversions in GIMP with ICC profiles from a Mac, but I can't seem to get the same colors you got in the screenshot. I'm using the teal (selected text) color as a guide: it's #327173 in the screenshot in the readme and no matter what I do, I can't get this color through conversion (it's listed in the source code as 23: '#007173').

I'll just parse the pictures with Pillow and get the colors from the screenshots.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from typing import Tuple

SEOUL256_RGB_COLORS = {
    22: "#006F00",
    23: "#007173",
    24: "#007299",
    25: "#0074BE",
    30: "#009799",
    31: "#0099BD",
    38: "#00BDDF",
    52: "#730B00",
    58: "#727100",
    59: "#727272",
    65: "#719872",
    66: "#719899",
    67: "#7299BC",
    68: "#719CDF",
    73: "#6FBCBD",
    74: "#70BDDF",
    88: "#9B1300",
    89: "#9B1D72",
    94: "#9A7200",
    95: "#9A7372",
    96: "#9A7599",
    101: "#999872",
    103: "#999ABD",
    108: "#98BC99",
    109: "#98BCBD",
    110: "#98BEDE",
    116: "#97DDDF",
    125: "#BF2172",
    131: "#BE7572",
    137: "#BE9873",
    143: "#BDBB72",
    144: "#BDBC98",
    145: "#BDBDBD",
    151: "#BCDDBD",
    152: "#BCDEDE",
    153: "#BCE0FF",
    161: "#E12672",
    168: "#E17899",
    173: "#E19972",
    174: "#E09B99",
    179: "#DFBC72",
    181: "#E0BEBC",
    184: "#DEDC00",
    186: "#DEDD99",
    187: "#DFDEBD",
    189: "#DFDFFF",
    216: "#FFBD98",
    217: "#FFBFBD",
    218: "#FFC0DE",
    220: "#FFDD00",
    222: "#FFDE99",
    224: "#FFDFDF",
    230: "#FFFFDF",
    231: "#FFFFFF",
    232: "#060606",
    233: "#171717",
    234: "#252525",
    235: "#333233",
    236: "#3F3F3F",
    237: "#4B4B4B",
    238: "#565656",
    239: "#616161",
    240: "#6B6B6B",
    241: "#757575",
    249: "#BFBFBF",
    250: "#C8C8C8",
    251: "#D1D0D1",
    252: "#D9D9D9",
    253: "#E1E1E1",
    254: "#E9E9E9",
    255: "#F1F1F1",
}

RESET_COLOR_SEQ = "\x1b[0m"


def hex_to_rgb(value: str) -> int:
    value = value.lstrip("#")

    length = len(value)
    step = int(length / 3)
    return tuple(int(value[i : i + step], 16) for i in range(0, length, step))


def generate_set_rgb_background_seq(red: int, green: int, blue: int) -> str:
    return f"\x1b[48;2;{red};{green};{blue}m"


def generate_set_rgb_foreground_seq(red: int, green: int, blue: int) -> str:
    return f"\x1b[38;2;{red};{green};{blue}m"


def generate_set_ansi_background_seq(value: int) -> str:
    return f"\x1b[48;5;{value}m"


def generate_set_ansi_foreground_seq(value: int) -> str:
    return f"\x1b[38;5;{value}m"


def surround_text_with_rgb_bg_codes(
    text: str, color: Tuple[int, int, int]
) -> str:
    begin_seq = generate_set_rgb_background_seq(*color)
    return f"{begin_seq}{text}{RESET_COLOR_SEQ}"


def surround_text_with_ansi_bg_codes(text: str, color: int) -> str:
    begin_seq = generate_set_ansi_background_seq(color)
    return f"{begin_seq}{text}{RESET_COLOR_SEQ}"


def main() -> None:
    print("RGB codes specified in the theme")
    for name, hex_str in SEOUL256_RGB_COLORS.items():
        color_triplet = hex_to_rgb(hex_str)
        print(
            str(name).ljust(4),
            surround_text_with_rgb_bg_codes(" " * 10, color_triplet),
        )

    print("ANSI codes specified in the theme")
    for color_ansi in SEOUL256_RGB_COLORS:
        print(
            str(color_ansi).ljust(4),
            surround_text_with_ansi_bg_codes(" " * 10, color_ansi),
        )


if __name__ == "__main__":
    main()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants