Expand color and interpolate modules with color spaces, interpolators, and schemes - #595
Draft
cedrickcooke wants to merge 5 commits into
Draft
Expand color and interpolate modules with color spaces, interpolators, and schemes#595cedrickcooke wants to merge 5 commits into
cedrickcooke wants to merge 5 commits into
Conversation
Port d3-color color-space representations with conversions to and from the canonical ARGB Color, brighter/darker operations, and functional-syntax (rgb()/hsl()) parsing in ToColor. Co-authored-by: Cedrick Cooke <development@cedrickc.net>
Port d3-interpolate color interpolators: interpolateRgb (with gamma), interpolateHsl/HslLong, interpolateLab, interpolateHcl/HclLong, and interpolateCubehelix/CubehelixLong. Each interpolates in its color space and returns a Color. Co-authored-by: Cedrick Cooke <development@cedrickc.net>
Port d3-interpolate general interpolators: interpolateRound, interpolateString (embedded numbers), interpolateList, piecewise, interpolateBasis/BasisClosed (plus RGB basis splines), quantize, and interpolateDiscrete. Co-authored-by: Cedrick Cooke <development@cedrickc.net>
Add categorical scheme* palettes (Category10, Tableau10, Set1/2/3) and sequential/diverging control points (Blues, Greens, Reds, Greys, Viridis, RdBu, Spectral) in the color module, plus matching continuous interpolate* values in the interpolate module. Regenerate API dumps. Co-authored-by: Cedrick Cooke <development@cedrickc.net>
Rename Cubehelix's A-E coefficients to channel/trig names, Lab's white-point and CIE transfer constants, and the single-letter color-space fields (h/s/l/c -> hue/saturation/lightness/chroma). Regenerate API dumps. Co-authored-by: Cedrick Cooke <development@cedrickc.net>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Expands the
color(~ d3-color) andinterpolate(~ d3-interpolate) modules and adds color schemes (~ d3-scale-chromatic). Allinterpolatechanges are additive (new files and new functions only); no existing signatures inInterpolator.kt,BidirectionalInterpolator.kt, orInverter.ktwere touched.1. Color spaces (
color)Hsl,Lab,Hcl(withlch(...)builder), andCubehelixrepresentations, each with conversions to/from the canonical ARGBColor(toHsl/toLab/toHcl/toCubehelixandtoColor), andbrighter()/darker().Color.brighter()/Color.darker()(RGB-channel scaling, as in d3).ToColor.kt:rgb(...),rgb(%),rgba(...),hsl(...),hsla(...). Existing hex/keyword parsing is unchanged.2. Color interpolators (
interpolate)interpolateRgb(withgamma),interpolateHsl/interpolateHslLong,interpolateLab,interpolateHcl/interpolateHclLong,interpolateCubehelix/interpolateCubehelixLong. Each interpolates in its color space and returns aColor.3. General interpolators (
interpolate)interpolateRound,interpolateString(embedded numbers),interpolateList,piecewise,interpolateBasis/interpolateBasisClosed(+interpolateRgbBasis/interpolateRgbBasisClosed),quantize,interpolateDiscrete.4. Color schemes
scheme*palettes incolor: categorical (schemeCategory10,schemeTableau10,schemeSet1/2/3) and sequential/diverging control points (schemeBlues,schemeGreens,schemeReds,schemeGreys,schemeViridis,schemeRdBu,schemeSpectral).interpolate*values ininterpolate(e.g.interpolateBlues,interpolateViridis,interpolateRdBu,interpolateSpectral). These live ininterpolatebecause the continuous ramps depend oninterpolateRgbBasis, andcolorcannot depend oninterpolate(dependency direction isinterpolate→color). Viridis uses nearest-swatch sampling of its 256-swatch palette, matching d3.Testing
d3-color/d3-interpolate/d3-scale-chromaticpackages../gradlew :color:jvmTest :interpolate:jvmTestpasses; all non-Android platforms (JVM, JS, WasmJs, iosArm64, iosSimulatorArm64, macosArm64) compile.lintKotlinpasses;apiDumpregenerated andapiCheckpasses.Notes
:color:build/:interpolate:buildcould not complete in this environment only because no Android SDK is installed (SDK location not found); all non-Android targets build and JVM tests pass. The modules contain no Android-specific source.