ScaleFixer
Fixes irregular lightness progression in ordered palettes.
Redistributes Oklch lightness evenly between the two endpoints of a palette
that is already ordered as a scale. The entry order and the palette keys are
left untouched, so a repaired palette keeps its semantics.
Methods
Report how far the palette lightness ramp is from an even progression.
The direction is always inferred from the endpoints, and the expected
values are the ones a default fix() call would produce.
issues: list<string>,
direction: 'ascending'|'descending'|null,
color_count: int,
current_lightness: array<int|string, float>,
expected_lightness: array<int|string, float>,
non_monotonic: list<int|string>,
max_step_deviation: float,
needs_repair: bool,
}
| Name | Type | Default |
|---|---|---|
$palette |
ColorPaletteInterface | - |
Rebuild the palette with evenly spaced Oklch lightness values.
Supported options:
- direction: "auto" (default), "ascending" or "descending". A forced
direction re-orients the ramp: the entries keep their position, but the
lower lightness bound moves to the end the direction asks for.
- min_lightness: lower Oklch lightness bound, defaults to the darkest endpoint.
- max_lightness: upper Oklch lightness bound, defaults to the lightest endpoint.
- preserve_hue: keep each hue (default true), otherwise apply the first entry hue.
- preserve_chroma: keep each chroma (default true), otherwise apply the first entry chroma.
- preserve_alpha: keep each alpha (default true), otherwise apply the first entry alpha.
Palettes with fewer than two colors have no ramp to repair and are returned as is.
| Name | Type | Default |
|---|---|---|
$palette |
ColorPaletteInterface | - |
$options |
array | [] |