Olian04 / Pelle

MIT License
1 stars 0 forks source link

Re-Implement color manipulation logic #4

Open Olian04 opened 2 years ago

Olian04 commented 2 years ago

Problem

The current color manipulation logic (found in the util/color folder) uses approximations for transforming between colors and color spaces. This limits what kind of util functions Pelle can provide.

Solution

Re-implement the current color logic using a library that implements the real scientific color transformations, for example Color.js or color-convert. This will make color transformations more deterministic and will allow for more complex util functions.

Alternate Solution

If the real scientific color transformations take up too much space or take too much time to evaluate. It might be better to move those more accurate color transforms into its own library. Which could then be used alongside Pelle.

import { createPaletteConstructor  } from 'pelle';
import { identity, lighten, darken, contrastText } from 'alternate-solution-lib';

const CustomPalette = createPaletteConstructor({
  main: identity,
  light: lighten,
  dark: darken,
  text: contrastText,
});

const palette = Palette({
  primary: '#f5a'
});

Known Issues

~Color.js doesn't have typescript support and there are no plans to add it.~ fixed as of https://github.com/LeaVerou/color.js/pull/221

Olian04 commented 1 year ago

Color libraries: