DEV Community

Cover image for Spectral.js: Realistic Color Mixing with Kubelka-Munk Theory
jQueryScript
jQueryScript

Posted on

Spectral.js: Realistic Color Mixing with Kubelka-Munk Theory

Spectral.js: a JavaScript library that simulates realistic paint mixing using Kubelka-Munk theory.

Key features:

  • Physics-based color blending using spectral reflectance curves
  • Produces realistic browns and greens when mixing complementary colors
  • Perceptually uniform color spaces (OKLab/OKLCh) for accurate gamut mapping
  • Tinting strength control to balance dominant pigments
  • GLSL shader support for WebGL projects
  • Zero dependencies, 64-bit precision calculations

Perfect for digital painting apps, color palette tools, and generative art where color accuracy matters.

Mix colors like actual pigments instead of getting muddy RGB results.

πŸ‘‰ Blog Post

πŸ‘‰ GitHub Repo

πŸ‘‰ Live Demo

Top comments (0)