mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-06-04 11:42:19 +00:00
Change default colour space for interpolation
This commit is contained in:
@@ -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";
|
||||
}
|
||||
|
||||
@@ -27,22 +27,22 @@ The <<.op colour-interpolate>> operator is used to interpolate colour values in
|
||||
[colour-interpolate:<colour space>:<hue adjuster>[<colourA>],[<colourB>]]
|
||||
```
|
||||
|
||||
* ''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.
|
||||
|
||||
<<interpolate-example "0 0.333 0.666 1 +[colour-interpolate:oklch[red],[purple]]" """
|
||||
For example, this filter expression will return 4 colours that smoothly blend from red to purple in the OKLCH colour space:
|
||||
<<interpolate-example "0 0.333 0.666 1 +[colour-interpolate:lch[red],[purple]]" """
|
||||
For example, this filter expression will return 4 colours that smoothly blend from red to purple in the LCh colour space:
|
||||
""">>
|
||||
|
||||
<<interpolate-example "[range[0],[1],[0.05]colour-interpolate:oklch[red],[purple]]" """
|
||||
<<interpolate-example "[range[0],[1],[0.05]colour-interpolate:lch[red],[purple]]" """
|
||||
The range operator can be used to generate a series of weights:
|
||||
""">>
|
||||
|
||||
<<interpolate-example "[range[0],[1],[0.05]colour-interpolate:oklch:raw[red],[purple]]" """
|
||||
<<interpolate-example "[range[0],[1],[0.05]colour-interpolate:lch:raw[red],[purple]]" """
|
||||
Notice how the ''raw'' hue adjuster produces a rainbow effect:
|
||||
""">>
|
||||
|
||||
@@ -50,6 +50,10 @@ Notice how the ''raw'' hue adjuster produces a rainbow effect:
|
||||
Interpolations can be appended together:
|
||||
""">>
|
||||
|
||||
<<interpolate-example "[range[0],[1],[0.1]colour-interpolate:lch[#FAEEC6],[#BE9207]] =[range[0.1],[1],[0.1]colour-interpolate:lch[#BE9207],[#241E08]]" """
|
||||
Pleasing colour graduations can be created:
|
||||
""">>
|
||||
|
||||
See also the following related operators:
|
||||
|
||||
* <<.olink colour-get-oklch>> to retrieve a component of a colour value in the OKLCH colour space
|
||||
|
||||
Reference in New Issue
Block a user