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

Question: is it possible to create a custom color? #211

Open
Integralist opened this issue Oct 17, 2023 · 6 comments
Open

Question: is it possible to create a custom color? #211

Integralist opened this issue Oct 17, 2023 · 6 comments

Comments

@Integralist
Copy link

👋🏻

I've been through the entire README and I couldn't find any way to create my own color.

Is this possible? If so could someone explain how.

Thanks!

@fatih
Copy link
Owner

fatih commented Nov 10, 2023

Hi @Integralist

We only support 4-bit ANSI color codes. No 8-bit (256 colors) or RBG (16 million colors) are supported at this time.

See https://notes.burke.libbey.me/ansi-escape-codes/ and https://stackoverflow.com/questions/4842424/list-of-ansi-color-escape-sequences for more information.

I doubt I have the time to add support for more colors, though it's something we could pursue in the future.

@Integralist
Copy link
Author

Thanks @fatih for the links.

I guess adding more colours is fine if defining your own isn't possible.

I'll see if I can understand the code and what goes into defining your own colour (and if I can figure it out I'll open a PR).

@fatih
Copy link
Owner

fatih commented Mar 9, 2024

It looks like it's possible to add custom colors with RBG color codes, check this out:

#131 (comment)

I plan to add a new API or extend the Readme so people know how to use it.

@Integralist
Copy link
Author

Nice!! Thanks for the update ☺️

@Integralist
Copy link
Author

👋🏻

Sorry, only just circled back around to this.

What exactly are the first two inputs?

The latter three appear to be RGB from my testing but if I modify the 2nd argument at all then nothing works, and if I modify the 1st argument to be anything other than 38 or 48 again nothing works 🤔

I mean, it's fine, I've been able to figure out what I need to do...

c := color.New(color.Bold, 38, 2, 100, 0, 255).SprintFunc()
fmt.Printf("1: %s, 2: %s\n", c("prefix text"), "suffix text")

d := color.New(color.Bold, 48, 2, 100, 0, 255).SprintFunc()
fmt.Printf("1: %s, 2: %s\n", d("prefix text"), "suffix text")

...I'm just curious and would like to understand it.

Thanks!

@fatih
Copy link
Owner

fatih commented Mar 24, 2024

Hi @Integralist

I created a PR that provides ready to use API. Could you try it out and give any feedback you have there? #225

Thank you!

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

No branches or pull requests

2 participants