mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-09-25 02:31:43 +00:00
Add colour-lighten and colour-darken operators
This commit is contained in:
@@ -12,14 +12,13 @@ Color.js related utilities
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
var Color = require("$:/core/modules/utils/dom/color.js").Color;
|
||||
|
||||
/*
|
||||
For backwards compatibility
|
||||
*/
|
||||
exports.parseCSSColor = function(colourString) {
|
||||
var Color = require("$:/core/modules/utils/dom/color.js").Color,
|
||||
c = null;
|
||||
try {
|
||||
c = new Color(colourString);
|
||||
} catch(e) {
|
||||
// Do nothing on an error
|
||||
}
|
||||
var c = exports.parseCSSColorObject(colourString);
|
||||
if(c) {
|
||||
var rgb = c.srgb;
|
||||
return [rgb[0],rgb[1],rgb[2],c.alpha];
|
||||
@@ -28,4 +27,19 @@ exports.parseCSSColor = function(colourString) {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
Preferred way to parse a Color.js colour
|
||||
*/
|
||||
exports.parseCSSColorObject = function(colourString) {
|
||||
var Color = require("$:/core/modules/utils/dom/color.js").Color,
|
||||
c = null;
|
||||
try {
|
||||
c = new Color(colourString);
|
||||
} catch(e) {
|
||||
// Return null if there is an error
|
||||
}
|
||||
return c;
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user