1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-26 19:47:20 +00:00

Add expertimental colour-oklch operator

This commit is contained in:
Jeremy Ruston 2024-11-03 16:13:09 +00:00
parent 85fa913b1c
commit a8fb07137d
2 changed files with 29 additions and 2 deletions

View File

@ -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 = [];

View File

@ -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