Evercoder / Evercoder/culori

Conversion between `oklch` and `okhsl`

Open
#247 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.2k
Forks
38
PR merge metrics
No merged PRs in 30d

Description

I was playing around with the library and `converter`. When attempted, conversion from `oklch` to `okhsl` yields weird results. In the documentation I haven't seen any specifics about the the color spaces supported by converter. So I assume it is expected to work.

This is my converter function.

``` javascript
function colorConverter(mode, colorObject) {
let convertFunction = converter(mode);
let convertedColor = convertFunction(colorObject);

return convertedColor;
}
```

I have added,

``` javascript
useParser("--oklch", "oklch");
```

The function call is,

``` javascript
let elemColour = colorConverter(colorModes[i], defaultColour);
```
In that `colorModes` is

``` javascript
let colorModes = ["okhsl", "oklch"];
```

and, `defaultColour` is,

``` javascript
let defaultColour = {
mode: "oklch",
l: 0.2,
c: 0.1,
h: 230,
};
```

this is the results I'm getting,

![image](https://github.com/user-attachments/assets/6ad2d1ab-88d0-45d7-977a-914dec7c1d8e)

the values are,

``` javascript
Object { mode: "okhsl", l: 0.09907971332700131, s: -0.14929222272569598, h: 229.99999999999997 }
Object { mode: "oklch", l: 0.2, c: 0.1, h: 230 }
```

Is there anything I'm missing? Else it looks like there is some bug with converter function

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.