Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Conversation

@jordansissel
Copy link

  • 216-color RGB cube is supported as 'rgb' with range 0-5 for each color
  • 16-color Grayscale is supported as 'grayN' where N is 0-15

@jordansissel
Copy link
Author

@jordansissel
Copy link
Author

screen shot 2014-07-12 at 10 32 56 pm

@jordansissel
Copy link
Author

Ready for review!

Specific feedback requested:

  • Is the [rgb] syntax OK?
  • How about the [grayN] syntax?
  • Should we also add [greyN] for alternate spelling?
  • Need more tests?

* 216-color RGB cube is supported as 'rgb' with range 0-5 for each color
* 16-color Grayscale is supported as 'grayN' where N is 0-15
@jordansissel
Copy link
Author

  fmt.Printf("%s\n", colorstring.Color("[_200_]this should be red"))
  fmt.Printf("%s\n", colorstring.Color("[_020_]this should be green"))
  fmt.Printf("%s\n", colorstring.Color("[_002_]this should be blue"))
  fmt.Printf("%s\n", colorstring.Color("[_220_]this should be yellow"))
  fmt.Printf("%s\n", colorstring.Color("[_022_]this should be cyan"))
  fmt.Printf("%s\n", colorstring.Color("[_202_]this should be purple"))
  fmt.Printf("%s\n", colorstring.Color("[_222_]this should be grey"))

screen shot 2014-07-12 at 10 48 45 pm

@mitchellh
Copy link
Owner

Hey! Looks good. Questoin: why not just use the 256-color color number as shown here? http://misc.flogisoft.com/bash/tip_colors_and_formatting

Is the 0-6 "intensity" of a color some standard thing I'm unaware of? It might be easier to use the color numbers because then people can look it up. No?

@jordansissel
Copy link
Author

The reason for the rgb syntax is that the numbers don't really have semantic meaning. Like colors in the web, where we do #RRGGBB for 3 one-byte tuples (24 bit color), instead of say, using a 24bit value as a number (#8888FF is way more readable than 16734296, there's no sane relationship between the numbers). The #8888FF is "88" on a scale of 00 to FF for intensity of red and green, etc.

So terminal colors, is 216 colors of a 6x6x6 cube, so I picked base 6 (0-5) encoded as 3 digits RGB. Much easier for me to predict what a color will be [115] is 1 red, 1 green, 5 blue. Thinking in RGB is more natural to me, rather than having to compute this value before telling the computer what the terminal code for the color I want is.

@jordansissel
Copy link
Author

By way of example of the 'intensity' scale of rgb, here's what Apple Keynote offers for color selection for sliders of red, green, and blue. 0-255 here, but same principle applies to the 0-5 scale 216 colors gives us.
screen shot 2014-07-13 at 9 45 37 pm

@mitchellh
Copy link
Owner

This is reasonable. Let me take one quick review again tomorrow or tonight then I'll merge it in. Thanks!

@mpolden
Copy link

mpolden commented Jul 24, 2014

256 color support would be great. Any update on this?

@jippi
Copy link

jippi commented Oct 5, 2017

@mitchellh bump? ^ :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants