Skip to content

Conversion between oklch and okhsl #247

Open
@adithyaappu

Description

@adithyaappu

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.

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

  return convertedColor;
}

I have added,

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

The function call is,

let elemColour = colorConverter(colorModes[i], defaultColour);

In that colorModes is

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

and, defaultColour is,

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

this is the results I'm getting,

image

the values are,

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions