Ogeon / palette

A Rust library for linear color calculations and conversion
Apache License 2.0
749 stars 60 forks source link

Implements Rgba::from_str() #347

Closed rafaelbeckel closed 1 year ago

rafaelbeckel commented 1 year ago

This change implements the from_str() trait for the Rgba type, adding support for parsing a RGBA hex string with the format #rrggbbaa.

No related issue, no breaking changes.

Ogeon commented 1 year ago

Another thing to consider is to have an entirely different error type for rgba. I'm not sure how helpful it would be.

Ogeon commented 1 year ago

The tests should be fixed with #349, so you will have to rebase (or merge) this PR to get those changes here as well.

Ogeon commented 1 year ago

Anyway, I'm back from my adventures (some nice mountain hiking) and gave this another look. Apart from the error handling, I would suggest adding support for the 4 character shorthand format, too. It may not be as common, but I think it makes sense to at least be consistent with Rgb<S, u8> in that way. But that would be all!

rafaelbeckel commented 1 year ago

Another thing to consider is to have an entirely different error type for rgba. I'm not sure how helpful it would be.

I tried that, but it turned out to be too verbose, and the definitions became too far away from the usage. I decided to stick with a variant instead. It makes more sense semantically, too.

Ogeon commented 1 year ago

The code looks good and the tests are all green. 🙂 Thanks a lot!

Ogeon commented 1 year ago

bors r+

bors[bot] commented 1 year ago

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here. For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.