-
-
Notifications
You must be signed in to change notification settings - Fork 89
Description
Hello,
Thank you so much for developing this excellent library. I was imagining a feature that would be very useful. It is a variant of the current steps API.
let color = new Color("black");
color.steps("red", {
space: "lch",
outputSpace: "srgb",
maxDeltaE: 7, // max deltaE between consecutive steps
steps: 2 // min number of steps
});
The way I understand the current API is as follow:
- Take at least
stepssteps. - Each step should be no more than
maxDeltaE - Start at "black" and end at "red" - perfectly.
What I seek is a feature that accomplishes the following:
let color = new Color("rgb(100, 50, 50)");
color.steps("rgb(200, 50, 50)"), {
space: "lch",
outputSpace: "srgb",
minDeltaE: 7, // max deltaE between consecutive steps
exactNumberOfSteps: 16 // min number of steps
});
Imagine the start and end representing two points along the curve created by both interpolation and extrapolation. They are not the start and end of the resulting steps. The start/end colors (along with other parameters) define a curve in the color space that extends infinitely in both directions, and the start/end merely are points along that curve.
- I then want to take
exactNumberOfStepssamples from this curve. - It's just a "window" of discrete samples from the curve. The contrast between each step should be at least
minDeltaE. - As much as possible, the original start/end parameters should be in the window that is returned. The start/end don't need to actually be in the samples - but ideally they should be somewhere in the continuous curve that is bounded by the sampled discrete samples.
- It is not always possible for the start/end to be in that window. For example you could say
start=rgb(0, 0, 0)")end=rgb(255, 255, 255)"), and ask forexactNumberOfSteps=3withminDeltaE=1. That wouldn't produce enough range for the start/end points to be within the window. But the window could be centered in the start/end points. - Similarly, you might specify
start=rgb(100, 100, 100)")end=rgb(110, 110, 110)")and ask for16samples withminDeltaE=7. In that case, the window must extrapolate beyond the start/end points and the start/end points should be as centered as possible within the returned window without clipping. In summary: The window and start/end points should have the same midpoint as much as possible but no more than is possible.
The use case for this is that when creating color themes, people will want to define a starting/ending color - but a design system must create shades in between (or even outside of this range) in order to maintain minimum contrast between shades.
I don't believe this is possible with the current API, unless I'm mistaken.