mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 03:57:21 +00:00
Add expertimental colour-oklch operator
This commit is contained in:
parent
85fa913b1c
commit
a8fb07137d
@ -14,14 +14,23 @@ Filter operators for colour operations
|
|||||||
|
|
||||||
var Color = require("$:/core/modules/utils/dom/color.js").Color;
|
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));
|
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));
|
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) {
|
function makeColourOperator(fn) {
|
||||||
return function (source, operator, options) {
|
return function (source, operator, options) {
|
||||||
var results = [];
|
var results = [];
|
||||||
|
@ -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
|
Loading…
Reference in New Issue
Block a user