Add perceptual colour functions #40
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds the perceptual colour functions, which are familiar for users of CartoCSS (like me). I've also had to add a "mix" function since that isn't native to Chroma, along with a "mixp" variant that's not found in CartoCSS but seems reasonable to include.
Each function is tested, and for ease of comparison is tested alongside the chroma version. The chroma mixins for Integer were adapted for functions that require 0 and 2 parameters (e.g. greyscale and mix, respectively).
I've made a sense-check of each function against the output from CartoCSS, which indicated the algorithms are the same. There were about 3-4 cases where the output colour was 1-bit different in a particular colour channel. I assume that's a rounding issue and I don't think this is significant.
The only functions not implemented from CartoCSS are the "fadein/fadeout/fadeinp/fadeoutp" group, since they rely on colours having transparency. I'll open a separate issue for that.
Refs #10