spectre.console
spectre.console copied to clipboard
Added hex color conversion
Solves issue https://github.com/spectreconsole/spectre.console/issues/1354
I'm not sure if this is desired but seemed like an easy quality of life feature to allow hex to rgb for creating colors.
Please upvote :+1: this pull request if you are interested in it.
- I think
public static Color.FromHex(string hex)
would be a more desirable approach here from an API perspective.
I'd vote for a combination of public static Color ParseHex(string hex)
and public static bool TryParseHex(string hex, out Color color)
We use "ToHex" so "FromHex" and "TryFromHex" is more consistent API wise
It looks like hex[2..4]
is not supported in netstandard 2.0
Unfortunately, the build still breaks @jsheely - see the build log above, looks like simple char/string conversion error. Want to update and push again?
Thank you @jsheely, if no one else gets to it first, I'll review (and hopefully merge) your PR this week.
Dear @patriksvensson, I have rebased this branch, implemented full unit test coverage for both happy and unhappy paths, and ensured the failure to parse an invalid colour raises a FormatException
with (what seems to me) to be a reasonable message.
I think it's suitable for merging, please re-review when you can.
Do we want to support the short-hands for hex values? (E.g. using #a1b
instead of #aa11bb
)
Do we want to support the short-hands for hex values? (E.g. using
#a1b
instead of#aa11bb
)
You tell me @nils-a 😉, as someone who would like to merge this PR for me... I'm happy to implement the short color code if you'd like.
This (seemingly trivial) PR has been hanging around for too long for my liking.
This (seemingly trivial) PR has been hanging around for too long for my liking.
Agreed. Let's use it as it is.
@patriksvensson I feel your requested changes were addressed, right?
I'm pretty sure you want to merge this PR @nils-a . Remember that really nice, warm fuzzy feeling from doing so? It's waiting.