diff --git a/core/modules/filters/colour-ops.js b/core/modules/filters/colour-ops.js index 3ce9d1dca..1044f92a7 100644 --- a/core/modules/filters/colour-ops.js +++ b/core/modules/filters/colour-ops.js @@ -14,14 +14,23 @@ Filter operators for colour operations var Color = require("$:/core/modules/utils/dom/color.js").Color; -exports["colour-lighten"] = makeColourOperator(function (c, operator, operands) { +exports["colour-lighten"] = makeColourOperator(function (c, operator, options) { return c.lighten($tw.utils.parseNumber(operator.operand)); }); -exports["colour-darken"] = makeColourOperator(function (c, operator, operands) { +exports["colour-darken"] = makeColourOperator(function (c, operator, options) { return c.darken($tw.utils.parseNumber(operator.operand)); }); +exports["colour-oklch"] = makeColourOperator(function (c, operator, options) { + var prop = ((operator.suffixes || [])[0] || ["l"])[0]; +console.log("Prop",prop,$tw.utils.parseNumber(operator.operand)) + if(["l","c","h"].indexOf(prop) !== -1) { + c.oklch[prop] = $tw.utils.parseNumber(operator.operand); + } + return c; +}); + function makeColourOperator(fn) { return function (source, operator, options) { var results = []; diff --git a/editions/test/tiddlers/tests/data/operators/colour/ColourOklchL.tid b/editions/test/tiddlers/tests/data/operators/colour/ColourOklchL.tid new file mode 100644 index 000000000..22d6767f8 --- /dev/null +++ b/editions/test/tiddlers/tests/data/operators/colour/ColourOklchL.tid @@ -0,0 +1,18 @@ +title: Operators/Colour/ColourOklchL +description: Oklch colour function +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] + +title: Output + +\parsermode inline +\import [subfilter{$:/core/config/GlobalImportFilter}] +<$text text={{{ [subfilter{Filter}] }}}/> ++ +title: Filter + +=[function[colour],[primary]colour-oklch[0.5]] =[function[colour],[primary]colour-oklch:l[0.5]] +[join[,]] ++ +title: ExpectedResult + +#3d5bb8,#3d5bb8 \ No newline at end of file