-
Notifications
You must be signed in to change notification settings - Fork 191
feature:(#305) Add support for oklab
and oklch
color functions
#436
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
Conversation
…ctions __RESOLVES:__ _feature_ - *Add new CSS color functions* \[[microsoft#305](https://github.com/microsoft/vscode-css-languageservice/issues/305)\] __DESCRIPTION:__ CSS Color Module Level 4 adds support for `oklch` and `oklab` to browsers. They are becoming more popular, and I wanted to use them with color previews in my editor. This feature is built of of the original [microsoft#306](microsoft#306) which included steps for `lab` and `lch` but not the `ok` variants. Generally this code was designed using real world color [examples](https://www.oddcontrast.com/#hex__*f00__*4d216f80__srgb). __STEPS TO TEST:__
Any questions or concerns? Anything I can do to help move this along? |
@rgant Looks good, thanks a lot! |
export interface LAB { l: number; a: number; b: number; alpha?: number; } | ||
|
||
export function labFromLCH(l: number, c: number, h: number, alpha: number = 1.0): LAB { | ||
const DEGREES_TO_RADIANS_FACTOR = Math.PI / 180; |
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.
const DEGREES_TO_RADIANS_FACTOR = Math.PI / 180; | |
const DEGREES_TO_RADIANS_FACTOR = Math.PI / (DEGREES_PER_CIRCLE / 2); |
I think there should be a minor change here to re-use the constants better. Would you like that added to this PR, or a new one?
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.
Could also be const DEGREES_TO_RADIANS_FACTOR = Math.PI / DEGREES_PER_CIRCLE * 2;
If fewer parenthesis are preferred.
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.
You can make a follow-up PR, if you want. I think the brackets help, even if not strictly necessary.
RESOLVES:
feature - Add new CSS color functions [#305]
DESCRIPTION:
CSS Color Module Level 4 adds support for
oklch
andoklab
to browsers. They are becoming more popular, and I wanted to use them with color previews in my editor.This feature is built off of the original #306 which included steps for
lab
andlch
but not theok
variants.Generally this code was designed using real world color examples.
STEPS TO TEST:
Tests were added to relevant files following established patterns. Should be able to just run
npm run test
. However I don't use vscode, so I did not test in an actual editor.