From 77c99b418fa26557910dea1ae7b5c36a20d47123 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Sat, 21 Jun 2025 11:36:34 +0100 Subject: [PATCH] Change default colour space for interpolation --- core/modules/filters/colour-ops.js | 6 +++--- .../tiddlers/filters/colour-interpolate.tid | 14 +++++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/core/modules/filters/colour-ops.js b/core/modules/filters/colour-ops.js index 0c2426192..fa11f845a 100644 --- a/core/modules/filters/colour-ops.js +++ b/core/modules/filters/colour-ops.js @@ -82,12 +82,12 @@ exports["colour-best-contrast"] = makeParallelColourOperator(function (colours, exports["colour-interpolate"] = function(source,operator,options) { // Get the colour space suffix - var space = (((operator.suffixes || [])[0] || ["srgb"])[0]).toLowerCase(); + var space = ((((operator.suffixes || [])[0] || ["srgb"])[0]) || "").toLowerCase(); if(colourSpacesList.indexOf(space) === -1) { - space = "srgb"; + space = "lch"; } // Get the hue adjuster suffix - var hueAdjuster = (((operator.suffixes || [])[1] || ["shorter"])[0]).toLowerCase(); + var hueAdjuster = ((((operator.suffixes || [])[1] || ["shorter"])[0]) || "").toLowerCase(); if(hueAdjustersList.indexOf(hueAdjuster) === -1) { hueAdjuster = "shorter"; } diff --git a/editions/tw5.com/tiddlers/filters/colour-interpolate.tid b/editions/tw5.com/tiddlers/filters/colour-interpolate.tid index 9a463d65f..289b56230 100644 --- a/editions/tw5.com/tiddlers/filters/colour-interpolate.tid +++ b/editions/tw5.com/tiddlers/filters/colour-interpolate.tid @@ -27,22 +27,22 @@ The <<.op colour-interpolate>> operator is used to interpolate colour values in [colour-interpolate::[],[]] ``` -* ''colour space'': The name of the colour space to be used for the interpolation such as "OkLCh" or "sRGB". The full list of colour spaces that can be used for interpolation is given in [[Colour Spaces]] +* ''colour space'': The name of the colour space to be used for the interpolation such as "LCh" (the default), "OkLCh" or "sRGB". The full list of colour spaces that can be used for interpolation is given in [[Colour Spaces]] * ''hue adjuster'': For color spaces with a hue angle there are multiple ways to interpolate, which can produce drastically different results. The hue adjuster suffix allows the interpolation type to be controlled. It can be set to "raw", "increasing", "decreasing", "longer" or "shorter" (the default). See [[Colour Interpolation Hues]] for more details Two colour parameters are required. If there are fewer than two input colours, the operator will return an empty result. If there are more than two input colours, the operator will ignore the additional colours. Note that indexes outside the range 0 to 1 will extrapolate from the provided colour values. -<> -<> -<> @@ -50,6 +50,10 @@ Notice how the ''raw'' hue adjuster produces a rainbow effect: Interpolations can be appended together: """>> +<> + See also the following related operators: * <<.olink colour-get-oklch>> to retrieve a component of a colour value in the OKLCH colour space