Skip to content

"Passes Through" steps feature #676

@jordwalke

Description

@jordwalke

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 steps steps.
  • 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 exactNumberOfSteps samples 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 for exactNumberOfSteps=3 with minDeltaE=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 for 16 samples with minDeltaE=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.

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