Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
176: Rewrite the conversion traits to work more like From and Into r=Ogeon a=Ogeon This replaces the old `FromColor` and `IntoColor` traits, as well as the implementations of `From` and `Into` between color types, with new traits that are more flexible. The new `FromColor` and `IntoColor` traits will also clamp the output to prevent out-of-bounds results. It's a _very_ breaking change. To migrate from the old system, any failing uses `from` and `into` should be replaced with `from_color` and `into_color`. Any custom color that used to implement `IntoColor` should switch to implementing `FromColorUnclamped`. A new trait, called `Transparency`, has also been added to make it possible to implement `FromColorUnclamped` for `Alpha` without running into conflicting implementations. It makes it possible to convert from any color type that implements `Transparency`, and not just `Alpha<A, T>` to `Alpha<B, T>`, for example. The semantics of the new traits are a bit different, so it may affect type inference. It may also be necessary to convert using more than one step. This is mostly for the RGB family and Luma, when changing RGB space or standard. The syntax for the helper attributes were also changed to the more common `#[palette(...)]` pattern. It helped when implementing them and looks a bit nicer, IMO. Closes #41, fixes #111. Co-authored-by: Erik Hedvall <erikwhedvall@gmail.com>
- Loading branch information
Showing
52 changed files
with
2,926 additions
and
2,869 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.