color-js / color.js

Color conversion & manipulation library by the editors of the CSS Color specifications
https://colorjs.io
MIT License
1.81k stars 80 forks source link

`deltas()` function, closes #437 #532

Closed LeaVerou closed 1 month ago

netlify[bot] commented 1 month ago

Deploy Preview for colorjs ready!

Name Link
Latest commit be14c711ae78b26fa65b41801ca4c0e5487a2492
Latest deploy log https://app.netlify.com/sites/colorjs/deploys/665a02e833f16d00086d1fa9
Deploy Preview https://deploy-preview-532--colorjs.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

facelessuser commented 1 month ago

Shouldn't this have special handling for hues?

svgeesus commented 1 month ago

Shouldn't this have special handling for hues?

Yes, as I said earlier

LeaVerou commented 1 month ago

I envisioned this as a low-level utility function, if users want to make this optimization for hue it's trivial to do so on the deltas returned.

That said, it should definitely constrain the ΔH returned in some way (possibly by also preserving the original). We shouldn't have a color with a hue of 350 and a color with a hue of 0 appear to have a ΔΗ of 350. It seems like this could follow shorter hue, possibly even take an argument for it.

LeaVerou commented 1 month ago

Ok, I’ve made several improvements:

LeaVerou commented 1 month ago

We could have another option for scaling the Δh by taking C/L into account, but not sure how that would work in a generic way.

facelessuser commented 1 month ago

Looks good to me. I would fix lint issues. related to the files in questions.