Replies: 1 comment
-
Hi Marcel, thanks for the suggestion (and the kind words!). Since there’s a degree of customization involved in the output (clamping to gamut, rounding/number of decimals, etc.), I’m not sure the library can abstract away things significantly. We could add a method to serialize a color object as an array of ordered coordinates that works across color spaces, such as: import { formatArray, round } from 'culori';
formatArray(color).map(round(4)) => // [0..1, 0..1, 0..1] with four decimals
formatArray(color).map(v => Math.round(v * 255)) // [0..255, 0..255, 0..255] But I’m not really sure if that’s any easier than doing: [color.r, color.g, color.b].map(…) Is there a wide use for one specific kind of array representation we could use as rationale for implementing a |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Dan,
I'm using your library in one of my projects and it's great tbh. Thanks for your work.
I'm working with rgb array tuples and am constantly converting between arrays and culori's objects.
It would be really nice if you could add a function that does that automatically.
Maybe something like formatRgbArray(color) returning a [0..255, 0..255, 0..255] array.
And formatRgbArrayNormalized(color) returning a [0..1, 0..1, 0..1] array.
Anyway, please consider it and thanks again.
Beta Was this translation helpful? Give feedback.
All reactions