Skip to content

Expand color and interpolate modules with color spaces, interpolators, and schemes - #595

Draft
cedrickcooke wants to merge 5 commits into
mainfrom
cedrickc/cursor/color-interpolate-expansion-244e
Draft

Expand color and interpolate modules with color spaces, interpolators, and schemes#595
cedrickcooke wants to merge 5 commits into
mainfrom
cedrickc/cursor/color-interpolate-expansion-244e

Conversation

@cedrickcooke

Copy link
Copy Markdown
Collaborator

Summary

Expands the color (~ d3-color) and interpolate (~ d3-interpolate) modules and adds color schemes (~ d3-scale-chromatic). All interpolate changes are additive (new files and new functions only); no existing signatures in Interpolator.kt, BidirectionalInterpolator.kt, or Inverter.kt were touched.

1. Color spaces (color)

  • New Hsl, Lab, Hcl (with lch(...) builder), and Cubehelix representations, each with conversions to/from the canonical ARGB Color (toHsl/toLab/toHcl/toCubehelix and toColor), and brighter()/darker().
  • Color.brighter()/Color.darker() (RGB-channel scaling, as in d3).
  • Additive functional-syntax parsing in ToColor.kt: rgb(...), rgb(%), rgba(...), hsl(...), hsla(...). Existing hex/keyword parsing is unchanged.

2. Color interpolators (interpolate)

  • interpolateRgb (with gamma), interpolateHsl/interpolateHslLong, interpolateLab, interpolateHcl/interpolateHclLong, interpolateCubehelix/interpolateCubehelixLong. Each interpolates in its color space and returns a Color.

3. General interpolators (interpolate)

  • interpolateRound, interpolateString (embedded numbers), interpolateList, piecewise, interpolateBasis/interpolateBasisClosed (+ interpolateRgbBasis/interpolateRgbBasisClosed), quantize, interpolateDiscrete.

4. Color schemes

  • Discrete scheme* palettes in color: categorical (schemeCategory10, schemeTableau10, schemeSet1/2/3) and sequential/diverging control points (schemeBlues, schemeGreens, schemeReds, schemeGreys, schemeViridis, schemeRdBu, schemeSpectral).
  • Continuous interpolate* values in interpolate (e.g. interpolateBlues, interpolateViridis, interpolateRdBu, interpolateSpectral). These live in interpolate because the continuous ramps depend on interpolateRgbBasis, and color cannot depend on interpolate (dependency direction is interpolatecolor). Viridis uses nearest-swatch sampling of its 256-swatch palette, matching d3.

Testing

  • Added Kotlin common tests covering color-space round-trips and known d3 conversions, brighter/darker, functional parsing, all interpolators, and scheme values. Interpolation midpoints and scheme colors are verified against authoritative values generated from the actual d3-color/d3-interpolate/d3-scale-chromatic packages.
  • ./gradlew :color:jvmTest :interpolate:jvmTest passes; all non-Android platforms (JVM, JS, WasmJs, iosArm64, iosSimulatorArm64, macosArm64) compile.
  • lintKotlin passes; apiDump regenerated and apiCheck passes.

Notes

  • The full :color:build/:interpolate:build could 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.
Open in Web Open in Cursor 

cursoragent and others added 4 commits July 13, 2026 22:53
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>
@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown

Test Results

124 tests  +45   124 ✅ +45   2s ⏱️ ±0s
 20 suites + 5     0 💤 ± 0 
 20 files   + 5     0 ❌ ± 0 

Results for commit 3628eeb. ± Comparison against base commit 1589cbc.

♻️ This comment has been updated with latest results.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants