Skip to content
hoangm960Public

About

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

46 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Watercolor Unmixer

Pick the paints you have, pick the color you want, and get the mixing ratios that get closest to it.

The client sends the target and the available colors to a small Flask service, which mixes them subtractively in CMY space and minimizes the perceptual difference (CIE76 ΔE in Lab) with SLSQP.

Project layout

client/   React 19 + Vite + Tailwind 4
server/   Flask + numpy + scipy

Local development

Server

Python 3.11+ is required.

cd server
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
flask --app app run --port 5000

The API listens on http://localhost:5000.

Client

cd client
npm install
cp .env.example .env   # points the client at localhost:5000
npm run dev

Without a .env file the client uses the deployed Render backend.

Checks

cd client
npm run typecheck
npm run lint
npm test
npm run build

API

POST /api/mix

{
  "target_hex": "#a1b2c3",
  "input_colors": ["#ff0000", "#00ff00", "#0000ff"]
}

Response — an array in the same order as input_colors, so duplicate colors stay distinct:

[
  { "hex": "#ff0000", "weight": 0.52 },
  { "hex": "#00ff00", "weight": 0.31 },
  { "hex": "#0000ff", "weight": 0.17 }
]

target_hex and every entry in input_colors must be 3- or 6-digit hex colors. input_colors accepts 1 to 12 colors. Invalid input returns 400; a failed solve returns 422.

Known limitations

  • The CMY (1 - RGB) mixing model is a subtractive approximation, not a pigment model. Kubelka–Munk mixing would predict watercolor more accurately.
  • CIE76 is used for color difference; CIEDE2000 is closer to human perception.
  • The client normalizes colors to lowercase hex; the API echoes the input.

About

Resources

Stars

0 stars

Watchers

1 watching

Forks

Used by

Contributors

Languages