-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add color spaces for HSLuv and HPLuv #404
Conversation
✅ Deploy Preview for colorjs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
scripts/generate-hsluv-tests.js
Outdated
import { fileURLToPath } from "node:url"; | ||
import https from "node:https"; | ||
|
||
const testDataUrl = "https://raw.githubusercontent.com/hsluv/hsluv/ebe5f6fbe7082e04468a325b4c62f783e35987ad/snapshots/snapshot-rev4.json"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool idea to import the tests from that repo!
However, if we're gonna pin it to a specific commit, we may as well just copy the file over and import
it in the test. There is however value in loading the latest version of the file. Not sure what route you'd rather go with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test data hasn't changed in 8 years so I guess there's no value in pinning to a specific commit. I don't think the file will ever change and if changes are required a snapshot-rev5.json
will be created.
My preference right now would be to do the least amount of work. So either keep it as is or change the testDataUrl
to not reference a specific commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Walked the dog and changed my mind.
- I'll create a
test/hsluv
directory that contains a copy of the json test data and test files for hpluv and hsluv - the test files will load the json test data and create the appropriate tests
- the
test:generate-hsluv
script will be deleted npm run test:hsluv
will run the hsluv tests
I've revamped the tests:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move test/hsluv/hpluv.js
and test/hsluv/hsluv.js
to be directly into test
(and they can still import the files they need from hsluv/
. Other than that, LGTM.
Done |
Merged, thanks! 🎉 |
Add color spaces for HSLuv and HPLuv.
The conversion routines where adapted from the typescript source code in the HSLuv repository.
Tests
The HSLuv repository has test data in json format.
I added a script to generate tests suites for hpluv and hsluv.
npm run test:generate-hsluv
will createtest/hpluv.js
andtest/hsluv.js
. The tests take forever to load/run on my ancient Windows PC when run vianpm run test
. Running the individual test files is less bad. I've added the files to .gitignore so they aren't committed accidently.In Gamut Tests
I added a test suite for
inGamut()
and the various methods of specifying thegamutSpace
for a color space. HSLuv has agamutSpace
ofsrgb
and HPLuv has agamutSpace
of"self"
.Closes #339, closes #284