d3plus-color
Advanced tools
Comparing version 0.6.4 to 0.6.5
/* | ||
d3plus-color v0.6.4 | ||
d3plus-color v0.6.5 | ||
Color functions that extent the ability of d3-color. | ||
@@ -8,206 +8,7 @@ Copyright (c) 2019 D3plus - https://d3plus.org | ||
if (typeof Object.assign !== "function") { | ||
Object.defineProperty(Object, "assign", { | ||
value: function assign(target) { | ||
"use strict"; | ||
if (target === null) { | ||
throw new TypeError("Cannot convert undefined or null to object"); | ||
} | ||
var to = Object(target); | ||
for (var index = 1; index < arguments.length; index++) { | ||
var nextSource = arguments[index]; | ||
if (nextSource !== null) { | ||
for (var nextKey in nextSource) { | ||
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { | ||
to[nextKey] = nextSource[nextKey]; | ||
} | ||
} | ||
} | ||
} | ||
return to; | ||
}, | ||
writable: true, | ||
configurable: true | ||
}); | ||
} | ||
if (!Array.prototype.includes) { | ||
Object.defineProperty(Array.prototype, "includes", { | ||
value: function includes(searchElement, fromIndex) { | ||
var o = Object(this); | ||
var len = o.length >>> 0; | ||
if (len === 0) return false; | ||
var n = fromIndex | 0; | ||
var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0); | ||
function sameValueZero(x, y) { | ||
return x === y || typeof x === "number" && typeof y === "number" && isNaN(x) && isNaN(y); | ||
} | ||
while (k < len) { | ||
if (sameValueZero(o[k], searchElement)) { | ||
return true; | ||
} | ||
k++; | ||
} | ||
return false; | ||
} | ||
}); | ||
} | ||
if (!String.prototype.includes) { | ||
Object.defineProperty(String.prototype, 'includes', { | ||
value: function(search, start) { | ||
if (typeof start !== 'number') { | ||
start = 0 | ||
} | ||
if (start + search.length > this.length) { | ||
return false | ||
} else { | ||
return this.indexOf(search, start) !== -1 | ||
} | ||
} | ||
}) | ||
} | ||
if (!Array.prototype.find) { | ||
Object.defineProperty(Array.prototype, 'find', { | ||
value: function(predicate) { | ||
// 1. Let O be ? ToObject(this value). | ||
if (this == null) { | ||
throw new TypeError('"this" is null or not defined'); | ||
} | ||
var o = Object(this); | ||
// 2. Let len be ? ToLength(? Get(O, "length")). | ||
var len = o.length >>> 0; | ||
// 3. If IsCallable(predicate) is false, throw a TypeError exception. | ||
if (typeof predicate !== 'function') { | ||
throw new TypeError('predicate must be a function'); | ||
} | ||
// 4. If thisArg was supplied, let T be thisArg; else let T be undefined. | ||
var thisArg = arguments[1]; | ||
// 5. Let k be 0. | ||
var k = 0; | ||
// 6. Repeat, while k < len | ||
while (k < len) { | ||
// a. Let Pk be ! ToString(k). | ||
// b. Let kValue be ? Get(O, Pk). | ||
// c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). | ||
// d. If testResult is true, return kValue. | ||
var kValue = o[k]; | ||
if (predicate.call(thisArg, kValue, k, o)) { | ||
return kValue; | ||
} | ||
// e. Increase k by 1. | ||
k++; | ||
} | ||
// 7. Return undefined. | ||
return undefined; | ||
}, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} | ||
if (!String.prototype.startsWith) { | ||
Object.defineProperty(String.prototype, 'startsWith', { | ||
value: function(search, pos) { | ||
pos = !pos || pos < 0 ? 0 : +pos; | ||
return this.substring(pos, pos + search.length) === search; | ||
} | ||
}); | ||
} | ||
if (typeof window !== "undefined") { | ||
(function () { | ||
var serializeXML = function (node, output) { | ||
var nodeType = node.nodeType; | ||
if (nodeType === 3) { | ||
output.push(node.textContent.replace(/&/, '&').replace(/</, '<').replace('>', '>')); | ||
} else if (nodeType === 1) { | ||
output.push('<', node.tagName); | ||
if (node.hasAttributes()) { | ||
[].forEach.call(node.attributes, function(attrNode){ | ||
output.push(' ', attrNode.item.name, '=\'', attrNode.item.value, '\''); | ||
}) | ||
} | ||
if (node.hasChildNodes()) { | ||
output.push('>'); | ||
[].forEach.call(node.childNodes, function(childNode){ | ||
serializeXML(childNode, output); | ||
}) | ||
output.push('</', node.tagName, '>'); | ||
} else { | ||
output.push('/>'); | ||
} | ||
} else if (nodeType == 8) { | ||
output.push('<!--', node.nodeValue, '-->'); | ||
} | ||
} | ||
Object.defineProperty(SVGElement.prototype, 'innerHTML', { | ||
get: function () { | ||
var output = []; | ||
var childNode = this.firstChild; | ||
while (childNode) { | ||
serializeXML(childNode, output); | ||
childNode = childNode.nextSibling; | ||
} | ||
return output.join(''); | ||
}, | ||
set: function (markupText) { | ||
while (this.firstChild) { | ||
this.removeChild(this.firstChild); | ||
} | ||
try { | ||
var dXML = new DOMParser(); | ||
dXML.async = false; | ||
var sXML = '<svg xmlns=\'http://www.w3.org/2000/svg\' xmlns:xlink=\'http://www.w3.org/1999/xlink\'>' + markupText + '</svg>'; | ||
var svgDocElement = dXML.parseFromString(sXML, 'text/xml').documentElement; | ||
var childNode = svgDocElement.firstChild; | ||
while (childNode) { | ||
this.appendChild(this.ownerDocument.importNode(childNode, true)); | ||
childNode = childNode.nextSibling; | ||
} | ||
} catch (e) {}; | ||
} | ||
}); | ||
Object.defineProperty(SVGElement.prototype, 'innerSVG', { | ||
get: function () { | ||
return this.innerHTML; | ||
}, | ||
set: function (markup) { | ||
this.innerHTML = markup; | ||
} | ||
}); | ||
})(); | ||
} | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-color'), require('d3-scale')) : | ||
typeof define === 'function' && define.amd ? define('d3plus-color', ['exports', 'd3-color', 'd3-scale'], factory) : | ||
(factory((global.d3plus = {}),global.d3Color,global.d3Scale)); | ||
}(this, (function (exports,d3Color,d3Scale) { 'use strict'; | ||
(global = global || self, factory(global.d3plus = {}, global.d3Color, global.d3Scale)); | ||
}(this, function (exports, d3Color, d3Scale) { 'use strict'; | ||
@@ -223,17 +24,16 @@ /** | ||
*/ | ||
function add(c1, c2, o1, o2) { | ||
if ( o1 === void 0 ) o1 = 1; | ||
if ( o2 === void 0 ) o2 = 1; | ||
function add (c1, c2) { | ||
var o1 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; | ||
var o2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1; | ||
c1 = d3Color.hsl(c1); | ||
c2 = d3Color.hsl(c2); | ||
var d = Math.abs(c2.h * o2 - c1.h * o1); | ||
if (d > 180) { d -= 360; } | ||
if (d > 180) d -= 360; | ||
var h = (Math.min(c1.h, c2.h) + d / 2) % 360; | ||
var l = c1.l + (c2.l * o2 - c1.l * o1) / 2, | ||
s = c1.s + (c2.s * o2 - c1.s * o1) / 2; | ||
// a = o1 + (o2 - o1) / 2; | ||
if (h < 0) { h += 360; } | ||
return d3Color.hsl(("hsl(" + h + "," + (s * 100) + "%," + (l * 100) + "%)")).toString(); | ||
// return hsl(`hsl(${h},${s * 100}%,${l * 100}%,${a})`).toString(); | ||
s = c1.s + (c2.s * o2 - c1.s * o1) / 2; // a = o1 + (o2 - o1) / 2; | ||
if (h < 0) h += 360; | ||
return d3Color.hsl("hsl(".concat(h, ",").concat(s * 100, "%,").concat(l * 100, "%)")).toString(); // return hsl(`hsl(${h},${s * 100}%,${l * 100}%,${a})`).toString(); | ||
} | ||
@@ -254,2 +54,3 @@ | ||
*/ | ||
var defaults = { | ||
@@ -261,9 +62,4 @@ dark: "#444444", | ||
on: "#224f20", | ||
scale: d3Scale.scaleOrdinal().range([ | ||
"#b22200", "#282f6b", "#eace3f", "#b35c1e", "#224f20", "#5f487c", | ||
"#759143", "#419391", "#993c88", "#e89c89", "#ffee8d", "#afd5e8", | ||
"#f7ba77", "#a5c697", "#c5b5e5", "#d1d392", "#bbefd0", "#e099cf" | ||
]) | ||
scale: d3Scale.scaleOrdinal().range(["#b22200", "#282f6b", "#eace3f", "#b35c1e", "#224f20", "#5f487c", "#759143", "#419391", "#993c88", "#e89c89", "#ffee8d", "#afd5e8", "#f7ba77", "#a5c697", "#c5b5e5", "#d1d392", "#bbefd0", "#e099cf"]) | ||
}; | ||
/** | ||
@@ -274,5 +70,5 @@ Returns a color based on a key, whether it is present in a user supplied object or in the default object. | ||
*/ | ||
function getColor(k, u) { | ||
if ( u === void 0 ) u = {}; | ||
function getColor(k) { | ||
var u = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
return k in u ? u[k] : k in defaults ? defaults[k] : defaults.missing; | ||
@@ -288,19 +84,13 @@ } | ||
*/ | ||
function assign(c, u) { | ||
if ( u === void 0 ) u = {}; | ||
function assign (c) { | ||
var u = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
// If the value is null or undefined, set to grey. | ||
if ([null, void 0].indexOf(c) >= 0) { return getColor("missing", u); } | ||
// Else if the value is true, set to green. | ||
else if (c === true) { return getColor("on", u); } | ||
// Else if the value is false, set to red. | ||
else if (c === false) { return getColor("off", u); } | ||
if ([null, void 0].indexOf(c) >= 0) return getColor("missing", u); // Else if the value is true, set to green. | ||
else if (c === true) return getColor("on", u); // Else if the value is false, set to red. | ||
else if (c === false) return getColor("off", u); | ||
var p = d3Color.color(c); // If the value is not a valid color string, use the color scale. | ||
var p = d3Color.color(c); | ||
// If the value is not a valid color string, use the color scale. | ||
if (!p) { return getColor("scale", u)(c); } | ||
if (!p) return getColor("scale", u)(c); | ||
return c.toString(); | ||
} | ||
@@ -315,5 +105,5 @@ | ||
*/ | ||
function contrast(c, u) { | ||
if ( u === void 0 ) u = {}; | ||
function contrast (c) { | ||
var u = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
c = d3Color.rgb(c); | ||
@@ -330,8 +120,11 @@ var yiq = (c.r * 299 + c.g * 587 + c.b * 114) / 1000; | ||
*/ | ||
function legible(c) { | ||
function legible (c) { | ||
c = d3Color.hsl(c); | ||
if (c.l > 0.45) { | ||
if (c.s > 0.8) { c.s = 0.8; } | ||
if (c.s > 0.8) c.s = 0.8; | ||
c.l = 0.45; | ||
} | ||
return c.toString(); | ||
@@ -347,5 +140,5 @@ } | ||
*/ | ||
function lighter(c, i) { | ||
if ( i === void 0 ) i = 0.5; | ||
function lighter (c) { | ||
var i = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.5; | ||
c = d3Color.hsl(c); | ||
@@ -367,17 +160,16 @@ i *= 1 - c.l; | ||
*/ | ||
function subtract(c1, c2, o1, o2) { | ||
if ( o1 === void 0 ) o1 = 1; | ||
if ( o2 === void 0 ) o2 = 1; | ||
function subtract (c1, c2) { | ||
var o1 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; | ||
var o2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1; | ||
c1 = d3Color.hsl(c1); | ||
c2 = d3Color.hsl(c2); | ||
var d = c2.h * o2 - c1.h * o1; | ||
if (Math.abs(d) > 180) { d -= 360; } | ||
if (Math.abs(d) > 180) d -= 360; | ||
var h = (c1.h - d) % 360; | ||
var l = c1.l - (c2.l * o2 - c1.l * o1) / 2, | ||
s = c1.s - (c2.s * o2 - c1.s * o1) / 2; | ||
// a = o1 - (o2 - o1) / 2; | ||
if (h < 0) { h += 360; } | ||
return d3Color.hsl(("hsl(" + h + "," + (s * 100) + "%," + (l * 100) + "%)")).toString(); | ||
// return hsl(`hsl(${h},${s * 100}%,${l * 100}%,${a})`).toString(); | ||
s = c1.s - (c2.s * o2 - c1.s * o1) / 2; // a = o1 - (o2 - o1) / 2; | ||
if (h < 0) h += 360; | ||
return d3Color.hsl("hsl(".concat(h, ",").concat(s * 100, "%,").concat(l * 100, "%)")).toString(); // return hsl(`hsl(${h},${s * 100}%,${l * 100}%,${a})`).toString(); | ||
} | ||
@@ -395,3 +187,920 @@ | ||
}))); | ||
})); | ||
(function (factory) { | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
factory(); | ||
}(function () { 'use strict'; | ||
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
function createCommonjsModule(fn, module) { | ||
return module = { exports: {} }, fn(module, module.exports), module.exports; | ||
} | ||
var O = 'object'; | ||
var check = function (it) { | ||
return it && it.Math == Math && it; | ||
}; | ||
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 | ||
var global_1 = | ||
// eslint-disable-next-line no-undef | ||
check(typeof globalThis == O && globalThis) || | ||
check(typeof window == O && window) || | ||
check(typeof self == O && self) || | ||
check(typeof commonjsGlobal == O && commonjsGlobal) || | ||
// eslint-disable-next-line no-new-func | ||
Function('return this')(); | ||
var fails = function (exec) { | ||
try { | ||
return !!exec(); | ||
} catch (error) { | ||
return true; | ||
} | ||
}; | ||
// Thank's IE8 for his funny defineProperty | ||
var descriptors = !fails(function () { | ||
return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7; | ||
}); | ||
var nativePropertyIsEnumerable = {}.propertyIsEnumerable; | ||
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; | ||
// Nashorn ~ JDK8 bug | ||
var NASHORN_BUG = getOwnPropertyDescriptor && !nativePropertyIsEnumerable.call({ 1: 2 }, 1); | ||
// `Object.prototype.propertyIsEnumerable` method implementation | ||
// https://tc39.github.io/ecma262/#sec-object.prototype.propertyisenumerable | ||
var f = NASHORN_BUG ? function propertyIsEnumerable(V) { | ||
var descriptor = getOwnPropertyDescriptor(this, V); | ||
return !!descriptor && descriptor.enumerable; | ||
} : nativePropertyIsEnumerable; | ||
var objectPropertyIsEnumerable = { | ||
f: f | ||
}; | ||
var createPropertyDescriptor = function (bitmap, value) { | ||
return { | ||
enumerable: !(bitmap & 1), | ||
configurable: !(bitmap & 2), | ||
writable: !(bitmap & 4), | ||
value: value | ||
}; | ||
}; | ||
var toString = {}.toString; | ||
var classofRaw = function (it) { | ||
return toString.call(it).slice(8, -1); | ||
}; | ||
var split = ''.split; | ||
// fallback for non-array-like ES3 and non-enumerable old V8 strings | ||
var indexedObject = fails(function () { | ||
// throws an error in rhino, see https://github.com/mozilla/rhino/issues/346 | ||
// eslint-disable-next-line no-prototype-builtins | ||
return !Object('z').propertyIsEnumerable(0); | ||
}) ? function (it) { | ||
return classofRaw(it) == 'String' ? split.call(it, '') : Object(it); | ||
} : Object; | ||
// `RequireObjectCoercible` abstract operation | ||
// https://tc39.github.io/ecma262/#sec-requireobjectcoercible | ||
var requireObjectCoercible = function (it) { | ||
if (it == undefined) throw TypeError("Can't call method on " + it); | ||
return it; | ||
}; | ||
// toObject with fallback for non-array-like ES3 strings | ||
var toIndexedObject = function (it) { | ||
return indexedObject(requireObjectCoercible(it)); | ||
}; | ||
var isObject = function (it) { | ||
return typeof it === 'object' ? it !== null : typeof it === 'function'; | ||
}; | ||
// `ToPrimitive` abstract operation | ||
// https://tc39.github.io/ecma262/#sec-toprimitive | ||
// instead of the ES6 spec version, we didn't implement @@toPrimitive case | ||
// and the second argument - flag - preferred type is a string | ||
var toPrimitive = function (input, PREFERRED_STRING) { | ||
if (!isObject(input)) return input; | ||
var fn, val; | ||
if (PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val; | ||
if (typeof (fn = input.valueOf) == 'function' && !isObject(val = fn.call(input))) return val; | ||
if (!PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val; | ||
throw TypeError("Can't convert object to primitive value"); | ||
}; | ||
var hasOwnProperty = {}.hasOwnProperty; | ||
var has = function (it, key) { | ||
return hasOwnProperty.call(it, key); | ||
}; | ||
var document = global_1.document; | ||
// typeof document.createElement is 'object' in old IE | ||
var EXISTS = isObject(document) && isObject(document.createElement); | ||
var documentCreateElement = function (it) { | ||
return EXISTS ? document.createElement(it) : {}; | ||
}; | ||
// Thank's IE8 for his funny defineProperty | ||
var ie8DomDefine = !descriptors && !fails(function () { | ||
return Object.defineProperty(documentCreateElement('div'), 'a', { | ||
get: function () { return 7; } | ||
}).a != 7; | ||
}); | ||
var nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; | ||
// `Object.getOwnPropertyDescriptor` method | ||
// https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptor | ||
var f$1 = descriptors ? nativeGetOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) { | ||
O = toIndexedObject(O); | ||
P = toPrimitive(P, true); | ||
if (ie8DomDefine) try { | ||
return nativeGetOwnPropertyDescriptor(O, P); | ||
} catch (error) { /* empty */ } | ||
if (has(O, P)) return createPropertyDescriptor(!objectPropertyIsEnumerable.f.call(O, P), O[P]); | ||
}; | ||
var objectGetOwnPropertyDescriptor = { | ||
f: f$1 | ||
}; | ||
var anObject = function (it) { | ||
if (!isObject(it)) { | ||
throw TypeError(String(it) + ' is not an object'); | ||
} return it; | ||
}; | ||
var nativeDefineProperty = Object.defineProperty; | ||
// `Object.defineProperty` method | ||
// https://tc39.github.io/ecma262/#sec-object.defineproperty | ||
var f$2 = descriptors ? nativeDefineProperty : function defineProperty(O, P, Attributes) { | ||
anObject(O); | ||
P = toPrimitive(P, true); | ||
anObject(Attributes); | ||
if (ie8DomDefine) try { | ||
return nativeDefineProperty(O, P, Attributes); | ||
} catch (error) { /* empty */ } | ||
if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported'); | ||
if ('value' in Attributes) O[P] = Attributes.value; | ||
return O; | ||
}; | ||
var objectDefineProperty = { | ||
f: f$2 | ||
}; | ||
var hide = descriptors ? function (object, key, value) { | ||
return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value)); | ||
} : function (object, key, value) { | ||
object[key] = value; | ||
return object; | ||
}; | ||
var setGlobal = function (key, value) { | ||
try { | ||
hide(global_1, key, value); | ||
} catch (error) { | ||
global_1[key] = value; | ||
} return value; | ||
}; | ||
var shared = createCommonjsModule(function (module) { | ||
var SHARED = '__core-js_shared__'; | ||
var store = global_1[SHARED] || setGlobal(SHARED, {}); | ||
(module.exports = function (key, value) { | ||
return store[key] || (store[key] = value !== undefined ? value : {}); | ||
})('versions', []).push({ | ||
version: '3.1.3', | ||
mode: 'global', | ||
copyright: '© 2019 Denis Pushkarev (zloirock.ru)' | ||
}); | ||
}); | ||
var functionToString = shared('native-function-to-string', Function.toString); | ||
var WeakMap = global_1.WeakMap; | ||
var nativeWeakMap = typeof WeakMap === 'function' && /native code/.test(functionToString.call(WeakMap)); | ||
var id = 0; | ||
var postfix = Math.random(); | ||
var uid = function (key) { | ||
return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36); | ||
}; | ||
var keys = shared('keys'); | ||
var sharedKey = function (key) { | ||
return keys[key] || (keys[key] = uid(key)); | ||
}; | ||
var hiddenKeys = {}; | ||
var WeakMap$1 = global_1.WeakMap; | ||
var set, get, has$1; | ||
var enforce = function (it) { | ||
return has$1(it) ? get(it) : set(it, {}); | ||
}; | ||
var getterFor = function (TYPE) { | ||
return function (it) { | ||
var state; | ||
if (!isObject(it) || (state = get(it)).type !== TYPE) { | ||
throw TypeError('Incompatible receiver, ' + TYPE + ' required'); | ||
} return state; | ||
}; | ||
}; | ||
if (nativeWeakMap) { | ||
var store = new WeakMap$1(); | ||
var wmget = store.get; | ||
var wmhas = store.has; | ||
var wmset = store.set; | ||
set = function (it, metadata) { | ||
wmset.call(store, it, metadata); | ||
return metadata; | ||
}; | ||
get = function (it) { | ||
return wmget.call(store, it) || {}; | ||
}; | ||
has$1 = function (it) { | ||
return wmhas.call(store, it); | ||
}; | ||
} else { | ||
var STATE = sharedKey('state'); | ||
hiddenKeys[STATE] = true; | ||
set = function (it, metadata) { | ||
hide(it, STATE, metadata); | ||
return metadata; | ||
}; | ||
get = function (it) { | ||
return has(it, STATE) ? it[STATE] : {}; | ||
}; | ||
has$1 = function (it) { | ||
return has(it, STATE); | ||
}; | ||
} | ||
var internalState = { | ||
set: set, | ||
get: get, | ||
has: has$1, | ||
enforce: enforce, | ||
getterFor: getterFor | ||
}; | ||
var redefine = createCommonjsModule(function (module) { | ||
var getInternalState = internalState.get; | ||
var enforceInternalState = internalState.enforce; | ||
var TEMPLATE = String(functionToString).split('toString'); | ||
shared('inspectSource', function (it) { | ||
return functionToString.call(it); | ||
}); | ||
(module.exports = function (O, key, value, options) { | ||
var unsafe = options ? !!options.unsafe : false; | ||
var simple = options ? !!options.enumerable : false; | ||
var noTargetGet = options ? !!options.noTargetGet : false; | ||
if (typeof value == 'function') { | ||
if (typeof key == 'string' && !has(value, 'name')) hide(value, 'name', key); | ||
enforceInternalState(value).source = TEMPLATE.join(typeof key == 'string' ? key : ''); | ||
} | ||
if (O === global_1) { | ||
if (simple) O[key] = value; | ||
else setGlobal(key, value); | ||
return; | ||
} else if (!unsafe) { | ||
delete O[key]; | ||
} else if (!noTargetGet && O[key]) { | ||
simple = true; | ||
} | ||
if (simple) O[key] = value; | ||
else hide(O, key, value); | ||
// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative | ||
})(Function.prototype, 'toString', function toString() { | ||
return typeof this == 'function' && getInternalState(this).source || functionToString.call(this); | ||
}); | ||
}); | ||
var path = global_1; | ||
var aFunction = function (variable) { | ||
return typeof variable == 'function' ? variable : undefined; | ||
}; | ||
var getBuiltIn = function (namespace, method) { | ||
return arguments.length < 2 ? aFunction(path[namespace]) || aFunction(global_1[namespace]) | ||
: path[namespace] && path[namespace][method] || global_1[namespace] && global_1[namespace][method]; | ||
}; | ||
var ceil = Math.ceil; | ||
var floor = Math.floor; | ||
// `ToInteger` abstract operation | ||
// https://tc39.github.io/ecma262/#sec-tointeger | ||
var toInteger = function (argument) { | ||
return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor : ceil)(argument); | ||
}; | ||
var min = Math.min; | ||
// `ToLength` abstract operation | ||
// https://tc39.github.io/ecma262/#sec-tolength | ||
var toLength = function (argument) { | ||
return argument > 0 ? min(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991 | ||
}; | ||
var max = Math.max; | ||
var min$1 = Math.min; | ||
// Helper for a popular repeating case of the spec: | ||
// Let integer be ? ToInteger(index). | ||
// If integer < 0, let result be max((length + integer), 0); else let result be min(length, length). | ||
var toAbsoluteIndex = function (index, length) { | ||
var integer = toInteger(index); | ||
return integer < 0 ? max(integer + length, 0) : min$1(integer, length); | ||
}; | ||
// `Array.prototype.{ indexOf, includes }` methods implementation | ||
var createMethod = function (IS_INCLUDES) { | ||
return function ($this, el, fromIndex) { | ||
var O = toIndexedObject($this); | ||
var length = toLength(O.length); | ||
var index = toAbsoluteIndex(fromIndex, length); | ||
var value; | ||
// Array#includes uses SameValueZero equality algorithm | ||
// eslint-disable-next-line no-self-compare | ||
if (IS_INCLUDES && el != el) while (length > index) { | ||
value = O[index++]; | ||
// eslint-disable-next-line no-self-compare | ||
if (value != value) return true; | ||
// Array#indexOf ignores holes, Array#includes - not | ||
} else for (;length > index; index++) { | ||
if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0; | ||
} return !IS_INCLUDES && -1; | ||
}; | ||
}; | ||
var arrayIncludes = { | ||
// `Array.prototype.includes` method | ||
// https://tc39.github.io/ecma262/#sec-array.prototype.includes | ||
includes: createMethod(true), | ||
// `Array.prototype.indexOf` method | ||
// https://tc39.github.io/ecma262/#sec-array.prototype.indexof | ||
indexOf: createMethod(false) | ||
}; | ||
var indexOf = arrayIncludes.indexOf; | ||
var objectKeysInternal = function (object, names) { | ||
var O = toIndexedObject(object); | ||
var i = 0; | ||
var result = []; | ||
var key; | ||
for (key in O) !has(hiddenKeys, key) && has(O, key) && result.push(key); | ||
// Don't enum bug & hidden keys | ||
while (names.length > i) if (has(O, key = names[i++])) { | ||
~indexOf(result, key) || result.push(key); | ||
} | ||
return result; | ||
}; | ||
// IE8- don't enum bug keys | ||
var enumBugKeys = [ | ||
'constructor', | ||
'hasOwnProperty', | ||
'isPrototypeOf', | ||
'propertyIsEnumerable', | ||
'toLocaleString', | ||
'toString', | ||
'valueOf' | ||
]; | ||
var hiddenKeys$1 = enumBugKeys.concat('length', 'prototype'); | ||
// `Object.getOwnPropertyNames` method | ||
// https://tc39.github.io/ecma262/#sec-object.getownpropertynames | ||
var f$3 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { | ||
return objectKeysInternal(O, hiddenKeys$1); | ||
}; | ||
var objectGetOwnPropertyNames = { | ||
f: f$3 | ||
}; | ||
var f$4 = Object.getOwnPropertySymbols; | ||
var objectGetOwnPropertySymbols = { | ||
f: f$4 | ||
}; | ||
// all object keys, includes non-enumerable and symbols | ||
var ownKeys = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) { | ||
var keys = objectGetOwnPropertyNames.f(anObject(it)); | ||
var getOwnPropertySymbols = objectGetOwnPropertySymbols.f; | ||
return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys; | ||
}; | ||
var copyConstructorProperties = function (target, source) { | ||
var keys = ownKeys(source); | ||
var defineProperty = objectDefineProperty.f; | ||
var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f; | ||
for (var i = 0; i < keys.length; i++) { | ||
var key = keys[i]; | ||
if (!has(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key)); | ||
} | ||
}; | ||
var replacement = /#|\.prototype\./; | ||
var isForced = function (feature, detection) { | ||
var value = data[normalize(feature)]; | ||
return value == POLYFILL ? true | ||
: value == NATIVE ? false | ||
: typeof detection == 'function' ? fails(detection) | ||
: !!detection; | ||
}; | ||
var normalize = isForced.normalize = function (string) { | ||
return String(string).replace(replacement, '.').toLowerCase(); | ||
}; | ||
var data = isForced.data = {}; | ||
var NATIVE = isForced.NATIVE = 'N'; | ||
var POLYFILL = isForced.POLYFILL = 'P'; | ||
var isForced_1 = isForced; | ||
var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f; | ||
/* | ||
options.target - name of the target object | ||
options.global - target is the global object | ||
options.stat - export as static methods of target | ||
options.proto - export as prototype methods of target | ||
options.real - real prototype method for the `pure` version | ||
options.forced - export even if the native feature is available | ||
options.bind - bind methods to the target, required for the `pure` version | ||
options.wrap - wrap constructors to preventing global pollution, required for the `pure` version | ||
options.unsafe - use the simple assignment of property instead of delete + defineProperty | ||
options.sham - add a flag to not completely full polyfills | ||
options.enumerable - export as enumerable property | ||
options.noTargetGet - prevent calling a getter on target | ||
*/ | ||
var _export = function (options, source) { | ||
var TARGET = options.target; | ||
var GLOBAL = options.global; | ||
var STATIC = options.stat; | ||
var FORCED, target, key, targetProperty, sourceProperty, descriptor; | ||
if (GLOBAL) { | ||
target = global_1; | ||
} else if (STATIC) { | ||
target = global_1[TARGET] || setGlobal(TARGET, {}); | ||
} else { | ||
target = (global_1[TARGET] || {}).prototype; | ||
} | ||
if (target) for (key in source) { | ||
sourceProperty = source[key]; | ||
if (options.noTargetGet) { | ||
descriptor = getOwnPropertyDescriptor$1(target, key); | ||
targetProperty = descriptor && descriptor.value; | ||
} else targetProperty = target[key]; | ||
FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced); | ||
// contained in target | ||
if (!FORCED && targetProperty !== undefined) { | ||
if (typeof sourceProperty === typeof targetProperty) continue; | ||
copyConstructorProperties(sourceProperty, targetProperty); | ||
} | ||
// add a flag to not completely full polyfills | ||
if (options.sham || (targetProperty && targetProperty.sham)) { | ||
hide(sourceProperty, 'sham', true); | ||
} | ||
// extend global | ||
redefine(target, key, sourceProperty, options); | ||
} | ||
}; | ||
var aFunction$1 = function (it) { | ||
if (typeof it != 'function') { | ||
throw TypeError(String(it) + ' is not a function'); | ||
} return it; | ||
}; | ||
// optional / simple context binding | ||
var bindContext = function (fn, that, length) { | ||
aFunction$1(fn); | ||
if (that === undefined) return fn; | ||
switch (length) { | ||
case 0: return function () { | ||
return fn.call(that); | ||
}; | ||
case 1: return function (a) { | ||
return fn.call(that, a); | ||
}; | ||
case 2: return function (a, b) { | ||
return fn.call(that, a, b); | ||
}; | ||
case 3: return function (a, b, c) { | ||
return fn.call(that, a, b, c); | ||
}; | ||
} | ||
return function (/* ...args */) { | ||
return fn.apply(that, arguments); | ||
}; | ||
}; | ||
// `ToObject` abstract operation | ||
// https://tc39.github.io/ecma262/#sec-toobject | ||
var toObject = function (argument) { | ||
return Object(requireObjectCoercible(argument)); | ||
}; | ||
// `IsArray` abstract operation | ||
// https://tc39.github.io/ecma262/#sec-isarray | ||
var isArray = Array.isArray || function isArray(arg) { | ||
return classofRaw(arg) == 'Array'; | ||
}; | ||
var nativeSymbol = !!Object.getOwnPropertySymbols && !fails(function () { | ||
// Chrome 38 Symbol has incorrect toString conversion | ||
// eslint-disable-next-line no-undef | ||
return !String(Symbol()); | ||
}); | ||
var Symbol$1 = global_1.Symbol; | ||
var store$1 = shared('wks'); | ||
var wellKnownSymbol = function (name) { | ||
return store$1[name] || (store$1[name] = nativeSymbol && Symbol$1[name] | ||
|| (nativeSymbol ? Symbol$1 : uid)('Symbol.' + name)); | ||
}; | ||
var SPECIES = wellKnownSymbol('species'); | ||
// `ArraySpeciesCreate` abstract operation | ||
// https://tc39.github.io/ecma262/#sec-arrayspeciescreate | ||
var arraySpeciesCreate = function (originalArray, length) { | ||
var C; | ||
if (isArray(originalArray)) { | ||
C = originalArray.constructor; | ||
// cross-realm fallback | ||
if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined; | ||
else if (isObject(C)) { | ||
C = C[SPECIES]; | ||
if (C === null) C = undefined; | ||
} | ||
} return new (C === undefined ? Array : C)(length === 0 ? 0 : length); | ||
}; | ||
var push = [].push; | ||
// `Array.prototype.{ forEach, map, filter, some, every, find, findIndex }` methods implementation | ||
var createMethod$1 = function (TYPE) { | ||
var IS_MAP = TYPE == 1; | ||
var IS_FILTER = TYPE == 2; | ||
var IS_SOME = TYPE == 3; | ||
var IS_EVERY = TYPE == 4; | ||
var IS_FIND_INDEX = TYPE == 6; | ||
var NO_HOLES = TYPE == 5 || IS_FIND_INDEX; | ||
return function ($this, callbackfn, that, specificCreate) { | ||
var O = toObject($this); | ||
var self = indexedObject(O); | ||
var boundFunction = bindContext(callbackfn, that, 3); | ||
var length = toLength(self.length); | ||
var index = 0; | ||
var create = specificCreate || arraySpeciesCreate; | ||
var target = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined; | ||
var value, result; | ||
for (;length > index; index++) if (NO_HOLES || index in self) { | ||
value = self[index]; | ||
result = boundFunction(value, index, O); | ||
if (TYPE) { | ||
if (IS_MAP) target[index] = result; // map | ||
else if (result) switch (TYPE) { | ||
case 3: return true; // some | ||
case 5: return value; // find | ||
case 6: return index; // findIndex | ||
case 2: push.call(target, value); // filter | ||
} else if (IS_EVERY) return false; // every | ||
} | ||
} | ||
return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target; | ||
}; | ||
}; | ||
var arrayIteration = { | ||
// `Array.prototype.forEach` method | ||
// https://tc39.github.io/ecma262/#sec-array.prototype.foreach | ||
forEach: createMethod$1(0), | ||
// `Array.prototype.map` method | ||
// https://tc39.github.io/ecma262/#sec-array.prototype.map | ||
map: createMethod$1(1), | ||
// `Array.prototype.filter` method | ||
// https://tc39.github.io/ecma262/#sec-array.prototype.filter | ||
filter: createMethod$1(2), | ||
// `Array.prototype.some` method | ||
// https://tc39.github.io/ecma262/#sec-array.prototype.some | ||
some: createMethod$1(3), | ||
// `Array.prototype.every` method | ||
// https://tc39.github.io/ecma262/#sec-array.prototype.every | ||
every: createMethod$1(4), | ||
// `Array.prototype.find` method | ||
// https://tc39.github.io/ecma262/#sec-array.prototype.find | ||
find: createMethod$1(5), | ||
// `Array.prototype.findIndex` method | ||
// https://tc39.github.io/ecma262/#sec-array.prototype.findIndex | ||
findIndex: createMethod$1(6) | ||
}; | ||
// `Object.keys` method | ||
// https://tc39.github.io/ecma262/#sec-object.keys | ||
var objectKeys = Object.keys || function keys(O) { | ||
return objectKeysInternal(O, enumBugKeys); | ||
}; | ||
// `Object.defineProperties` method | ||
// https://tc39.github.io/ecma262/#sec-object.defineproperties | ||
var objectDefineProperties = descriptors ? Object.defineProperties : function defineProperties(O, Properties) { | ||
anObject(O); | ||
var keys = objectKeys(Properties); | ||
var length = keys.length; | ||
var index = 0; | ||
var key; | ||
while (length > index) objectDefineProperty.f(O, key = keys[index++], Properties[key]); | ||
return O; | ||
}; | ||
var html = getBuiltIn('document', 'documentElement'); | ||
var IE_PROTO = sharedKey('IE_PROTO'); | ||
var PROTOTYPE = 'prototype'; | ||
var Empty = function () { /* empty */ }; | ||
// Create object with fake `null` prototype: use iframe Object with cleared prototype | ||
var createDict = function () { | ||
// Thrash, waste and sodomy: IE GC bug | ||
var iframe = documentCreateElement('iframe'); | ||
var length = enumBugKeys.length; | ||
var lt = '<'; | ||
var script = 'script'; | ||
var gt = '>'; | ||
var js = 'java' + script + ':'; | ||
var iframeDocument; | ||
iframe.style.display = 'none'; | ||
html.appendChild(iframe); | ||
iframe.src = String(js); | ||
iframeDocument = iframe.contentWindow.document; | ||
iframeDocument.open(); | ||
iframeDocument.write(lt + script + gt + 'document.F=Object' + lt + '/' + script + gt); | ||
iframeDocument.close(); | ||
createDict = iframeDocument.F; | ||
while (length--) delete createDict[PROTOTYPE][enumBugKeys[length]]; | ||
return createDict(); | ||
}; | ||
// `Object.create` method | ||
// https://tc39.github.io/ecma262/#sec-object.create | ||
var objectCreate = Object.create || function create(O, Properties) { | ||
var result; | ||
if (O !== null) { | ||
Empty[PROTOTYPE] = anObject(O); | ||
result = new Empty(); | ||
Empty[PROTOTYPE] = null; | ||
// add "__proto__" for Object.getPrototypeOf polyfill | ||
result[IE_PROTO] = O; | ||
} else result = createDict(); | ||
return Properties === undefined ? result : objectDefineProperties(result, Properties); | ||
}; | ||
hiddenKeys[IE_PROTO] = true; | ||
var UNSCOPABLES = wellKnownSymbol('unscopables'); | ||
var ArrayPrototype = Array.prototype; | ||
// Array.prototype[@@unscopables] | ||
// https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables | ||
if (ArrayPrototype[UNSCOPABLES] == undefined) { | ||
hide(ArrayPrototype, UNSCOPABLES, objectCreate(null)); | ||
} | ||
// add a key to Array.prototype[@@unscopables] | ||
var addToUnscopables = function (key) { | ||
ArrayPrototype[UNSCOPABLES][key] = true; | ||
}; | ||
var $find = arrayIteration.find; | ||
var FIND = 'find'; | ||
var SKIPS_HOLES = true; | ||
// Shouldn't skip holes | ||
if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; }); | ||
// `Array.prototype.find` method | ||
// https://tc39.github.io/ecma262/#sec-array.prototype.find | ||
_export({ target: 'Array', proto: true, forced: SKIPS_HOLES }, { | ||
find: function find(callbackfn /* , that = undefined */) { | ||
return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); | ||
} | ||
}); | ||
// https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables | ||
addToUnscopables(FIND); | ||
var $includes = arrayIncludes.includes; | ||
// `Array.prototype.includes` method | ||
// https://tc39.github.io/ecma262/#sec-array.prototype.includes | ||
_export({ target: 'Array', proto: true }, { | ||
includes: function includes(el /* , fromIndex = 0 */) { | ||
return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined); | ||
} | ||
}); | ||
// https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables | ||
addToUnscopables('includes'); | ||
var nativeAssign = Object.assign; | ||
// `Object.assign` method | ||
// https://tc39.github.io/ecma262/#sec-object.assign | ||
// should work with symbols and should have deterministic property order (V8 bug) | ||
var objectAssign = !nativeAssign || fails(function () { | ||
var A = {}; | ||
var B = {}; | ||
// eslint-disable-next-line no-undef | ||
var symbol = Symbol(); | ||
var alphabet = 'abcdefghijklmnopqrst'; | ||
A[symbol] = 7; | ||
alphabet.split('').forEach(function (chr) { B[chr] = chr; }); | ||
return nativeAssign({}, A)[symbol] != 7 || objectKeys(nativeAssign({}, B)).join('') != alphabet; | ||
}) ? function assign(target, source) { // eslint-disable-line no-unused-vars | ||
var T = toObject(target); | ||
var argumentsLength = arguments.length; | ||
var index = 1; | ||
var getOwnPropertySymbols = objectGetOwnPropertySymbols.f; | ||
var propertyIsEnumerable = objectPropertyIsEnumerable.f; | ||
while (argumentsLength > index) { | ||
var S = indexedObject(arguments[index++]); | ||
var keys = getOwnPropertySymbols ? objectKeys(S).concat(getOwnPropertySymbols(S)) : objectKeys(S); | ||
var length = keys.length; | ||
var j = 0; | ||
var key; | ||
while (length > j) { | ||
key = keys[j++]; | ||
if (!descriptors || propertyIsEnumerable.call(S, key)) T[key] = S[key]; | ||
} | ||
} return T; | ||
} : nativeAssign; | ||
// `Object.assign` method | ||
// https://tc39.github.io/ecma262/#sec-object.assign | ||
_export({ target: 'Object', stat: true, forced: Object.assign !== objectAssign }, { | ||
assign: objectAssign | ||
}); | ||
var MATCH = wellKnownSymbol('match'); | ||
// `IsRegExp` abstract operation | ||
// https://tc39.github.io/ecma262/#sec-isregexp | ||
var isRegexp = function (it) { | ||
var isRegExp; | ||
return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classofRaw(it) == 'RegExp'); | ||
}; | ||
var notARegexp = function (it) { | ||
if (isRegexp(it)) { | ||
throw TypeError("The method doesn't accept regular expressions"); | ||
} return it; | ||
}; | ||
var MATCH$1 = wellKnownSymbol('match'); | ||
var correctIsRegexpLogic = function (METHOD_NAME) { | ||
var regexp = /./; | ||
try { | ||
'/./'[METHOD_NAME](regexp); | ||
} catch (e) { | ||
try { | ||
regexp[MATCH$1] = false; | ||
return '/./'[METHOD_NAME](regexp); | ||
} catch (f) { /* empty */ } | ||
} return false; | ||
}; | ||
var nativeStartsWith = ''.startsWith; | ||
var min$2 = Math.min; | ||
// `String.prototype.startsWith` method | ||
// https://tc39.github.io/ecma262/#sec-string.prototype.startswith | ||
_export({ target: 'String', proto: true, forced: !correctIsRegexpLogic('startsWith') }, { | ||
startsWith: function startsWith(searchString /* , position = 0 */) { | ||
var that = String(requireObjectCoercible(this)); | ||
notARegexp(searchString); | ||
var index = toLength(min$2(arguments.length > 1 ? arguments[1] : undefined, that.length)); | ||
var search = String(searchString); | ||
return nativeStartsWith | ||
? nativeStartsWith.call(that, search, index) | ||
: that.slice(index, index + search.length) === search; | ||
} | ||
}); | ||
if (typeof window !== "undefined") { | ||
(function () { | ||
var serializeXML = function (node, output) { | ||
var nodeType = node.nodeType; | ||
if (nodeType === 3) { | ||
output.push(node.textContent.replace(/&/, '&').replace(/</, '<').replace('>', '>')); | ||
} else if (nodeType === 1) { | ||
output.push('<', node.tagName); | ||
if (node.hasAttributes()) { | ||
[].forEach.call(node.attributes, function(attrNode){ | ||
output.push(' ', attrNode.item.name, '=\'', attrNode.item.value, '\''); | ||
}); | ||
} | ||
if (node.hasChildNodes()) { | ||
output.push('>'); | ||
[].forEach.call(node.childNodes, function(childNode){ | ||
serializeXML(childNode, output); | ||
}); | ||
output.push('</', node.tagName, '>'); | ||
} else { | ||
output.push('/>'); | ||
} | ||
} else if (nodeType == 8) { | ||
output.push('<!--', node.nodeValue, '-->'); | ||
} | ||
}; | ||
Object.defineProperty(SVGElement.prototype, 'innerHTML', { | ||
get: function () { | ||
var output = []; | ||
var childNode = this.firstChild; | ||
while (childNode) { | ||
serializeXML(childNode, output); | ||
childNode = childNode.nextSibling; | ||
} | ||
return output.join(''); | ||
}, | ||
set: function (markupText) { | ||
while (this.firstChild) { | ||
this.removeChild(this.firstChild); | ||
} | ||
try { | ||
var dXML = new DOMParser(); | ||
dXML.async = false; | ||
var sXML = '<svg xmlns=\'http://www.w3.org/2000/svg\' xmlns:xlink=\'http://www.w3.org/1999/xlink\'>' + markupText + '</svg>'; | ||
var svgDocElement = dXML.parseFromString(sXML, 'text/xml').documentElement; | ||
var childNode = svgDocElement.firstChild; | ||
while (childNode) { | ||
this.appendChild(this.ownerDocument.importNode(childNode, true)); | ||
childNode = childNode.nextSibling; | ||
} | ||
} catch (e) {} } | ||
}); | ||
Object.defineProperty(SVGElement.prototype, 'innerSVG', { | ||
get: function () { | ||
return this.innerHTML; | ||
}, | ||
set: function (markup) { | ||
this.innerHTML = markup; | ||
} | ||
}); | ||
})(); | ||
} | ||
})); | ||
//# sourceMappingURL=d3plus-color.js.map |
/* | ||
d3plus-color v0.6.4 | ||
d3plus-color v0.6.5 | ||
Color functions that extent the ability of d3-color. | ||
@@ -7,2 +7,2 @@ Copyright (c) 2019 D3plus - https://d3plus.org | ||
*/ | ||
if(typeof Object.assign!=="function"){Object.defineProperty(Object,"assign",{value:function e(t){"use strict";if(t===null){throw new TypeError("Cannot convert undefined or null to object")}var r=Object(t);for(var i=1;i<arguments.length;i++){var n=arguments[i];if(n!==null){for(var o in n){if(Object.prototype.hasOwnProperty.call(n,o)){r[o]=n[o]}}}}return r},writable:true,configurable:true})}if(!Array.prototype.includes){Object.defineProperty(Array.prototype,"includes",{value:function e(t,r){var i=Object(this);var n=i.length>>>0;if(n===0)return false;var o=r|0;var f=Math.max(o>=0?o:n-Math.abs(o),0);function l(e,t){return e===t||typeof e==="number"&&typeof t==="number"&&isNaN(e)&&isNaN(t)}while(f<n){if(l(i[f],t)){return true}f++}return false}})}if(!String.prototype.includes){Object.defineProperty(String.prototype,"includes",{value:function(e,t){if(typeof t!=="number"){t=0}if(t+e.length>this.length){return false}else{return this.indexOf(e,t)!==-1}}})}if(!Array.prototype.find){Object.defineProperty(Array.prototype,"find",{value:function(e){if(this==null){throw new TypeError('"this" is null or not defined')}var t=Object(this);var r=t.length>>>0;if(typeof e!=="function"){throw new TypeError("predicate must be a function")}var i=arguments[1];var n=0;while(n<r){var o=t[n];if(e.call(i,o,n,t)){return o}n++}return undefined},configurable:true,writable:true})}if(!String.prototype.startsWith){Object.defineProperty(String.prototype,"startsWith",{value:function(e,t){t=!t||t<0?0:+t;return this.substring(t,t+e.length)===e}})}if(typeof window!=="undefined"){(function(){var i=function(e,t){var r=e.nodeType;if(r===3){t.push(e.textContent.replace(/&/,"&").replace(/</,"<").replace(">",">"))}else if(r===1){t.push("<",e.tagName);if(e.hasAttributes()){[].forEach.call(e.attributes,function(e){t.push(" ",e.item.name,"='",e.item.value,"'")})}if(e.hasChildNodes()){t.push(">");[].forEach.call(e.childNodes,function(e){i(e,t)});t.push("</",e.tagName,">")}else{t.push("/>")}}else if(r==8){t.push("\x3c!--",e.nodeValue,"--\x3e")}};Object.defineProperty(SVGElement.prototype,"innerHTML",{get:function(){var e=[];var t=this.firstChild;while(t){i(t,e);t=t.nextSibling}return e.join("")},set:function(e){while(this.firstChild){this.removeChild(this.firstChild)}try{var t=new DOMParser;t.async=false;var r="<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>"+e+"</svg>";var i=t.parseFromString(r,"text/xml").documentElement;var n=i.firstChild;while(n){this.appendChild(this.ownerDocument.importNode(n,true));n=n.nextSibling}}catch(e){}}});Object.defineProperty(SVGElement.prototype,"innerSVG",{get:function(){return this.innerHTML},set:function(e){this.innerHTML=e}})})()}(function(e,t){typeof exports==="object"&&typeof module!=="undefined"?t(exports,require("d3-color"),require("d3-scale")):typeof define==="function"&&define.amd?define("d3plus-color",["exports","d3-color","d3-scale"],t):t(e.d3plus={},e.d3Color,e.d3Scale)})(this,function(e,s,t){"use strict";function r(e,t,r,i){if(r===void 0)r=1;if(i===void 0)i=1;e=s.hsl(e);t=s.hsl(t);var n=Math.abs(t.h*i-e.h*r);if(n>180){n-=360}var o=(Math.min(e.h,t.h)+n/2)%360;var f=e.l+(t.l*i-e.l*r)/2,l=e.s+(t.s*i-e.s*r)/2;if(o<0){o+=360}return s.hsl("hsl("+o+","+l*100+"%,"+f*100+"%)").toString()}var i={dark:"#444444",light:"#f7f7f7",missing:"#cccccc",off:"#b22200",on:"#224f20",scale:t.scaleOrdinal().range(["#b22200","#282f6b","#eace3f","#b35c1e","#224f20","#5f487c","#759143","#419391","#993c88","#e89c89","#ffee8d","#afd5e8","#f7ba77","#a5c697","#c5b5e5","#d1d392","#bbefd0","#e099cf"])};function n(e,t){if(t===void 0)t={};return e in t?t[e]:e in i?i[e]:i.missing}function o(e,t){if(t===void 0)t={};if([null,void 0].indexOf(e)>=0){return n("missing",t)}else if(e===true){return n("on",t)}else if(e===false){return n("off",t)}var r=s.color(e);if(!r){return n("scale",t)(e)}return e.toString()}function f(e,t){if(t===void 0)t={};e=s.rgb(e);var r=(e.r*299+e.g*587+e.b*114)/1e3;return r>=128?n("dark",t):n("light",t)}function l(e){e=s.hsl(e);if(e.l>.45){if(e.s>.8){e.s=.8}e.l=.45}return e.toString()}function a(e,t){if(t===void 0)t=.5;e=s.hsl(e);t*=1-e.l;e.l+=t;e.s-=t;return e.toString()}function u(e,t,r,i){if(r===void 0)r=1;if(i===void 0)i=1;e=s.hsl(e);t=s.hsl(t);var n=t.h*i-e.h*r;if(Math.abs(n)>180){n-=360}var o=(e.h-n)%360;var f=e.l-(t.l*i-e.l*r)/2,l=e.s-(t.s*i-e.s*r)/2;if(o<0){o+=360}return s.hsl("hsl("+o+","+l*100+"%,"+f*100+"%)").toString()}e.colorAdd=r;e.colorAssign=o;e.colorContrast=f;e.colorDefaults=i;e.colorLegible=l;e.colorLighter=a;e.colorSubtract=u;Object.defineProperty(e,"__esModule",{value:true})}); | ||
(function(r,e){typeof exports==="object"&&typeof module!=="undefined"?e(exports,require("d3-color"),require("d3-scale")):typeof define==="function"&&define.amd?define("d3plus-color",["exports","d3-color","d3-scale"],e):(r=r||self,e(r.d3plus={},r.d3Color,r.d3Scale))})(this,function(r,f,e){"use strict";function n(r,e){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:1;var t=arguments.length>3&&arguments[3]!==undefined?arguments[3]:1;r=f.hsl(r);e=f.hsl(e);var a=Math.abs(e.h*t-r.h*n);if(a>180)a-=360;var i=(Math.min(r.h,e.h)+a/2)%360;var o=r.l+(e.l*t-r.l*n)/2,u=r.s+(e.s*t-r.s*n)/2;if(i<0)i+=360;return f.hsl("hsl(".concat(i,",").concat(u*100,"%,").concat(o*100,"%)")).toString()}var t={dark:"#444444",light:"#f7f7f7",missing:"#cccccc",off:"#b22200",on:"#224f20",scale:e.scaleOrdinal().range(["#b22200","#282f6b","#eace3f","#b35c1e","#224f20","#5f487c","#759143","#419391","#993c88","#e89c89","#ffee8d","#afd5e8","#f7ba77","#a5c697","#c5b5e5","#d1d392","#bbefd0","#e099cf"])};function a(r){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return r in e?e[r]:r in t?t[r]:t.missing}function i(r){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};if([null,void 0].indexOf(r)>=0)return a("missing",e);else if(r===true)return a("on",e);else if(r===false)return a("off",e);var n=f.color(r);if(!n)return a("scale",e)(r);return r.toString()}function o(r){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};r=f.rgb(r);var n=(r.r*299+r.g*587+r.b*114)/1e3;return n>=128?a("dark",e):a("light",e)}function u(r){r=f.hsl(r);if(r.l>.45){if(r.s>.8)r.s=.8;r.l=.45}return r.toString()}function c(r){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:.5;r=f.hsl(r);e*=1-r.l;r.l+=e;r.s-=e;return r.toString()}function l(r,e){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:1;var t=arguments.length>3&&arguments[3]!==undefined?arguments[3]:1;r=f.hsl(r);e=f.hsl(e);var a=e.h*t-r.h*n;if(Math.abs(a)>180)a-=360;var i=(r.h-a)%360;var o=r.l-(e.l*t-r.l*n)/2,u=r.s-(e.s*t-r.s*n)/2;if(i<0)i+=360;return f.hsl("hsl(".concat(i,",").concat(u*100,"%,").concat(o*100,"%)")).toString()}r.colorAdd=n;r.colorAssign=i;r.colorContrast=o;r.colorDefaults=t;r.colorLegible=u;r.colorLighter=c;r.colorSubtract=l;Object.defineProperty(r,"__esModule",{value:true})});(function(r){typeof define==="function"&&define.amd?define(r):r()})(function(){"use strict";var r=typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:typeof global!=="undefined"?global:typeof self!=="undefined"?self:{};function e(r,e){return e={exports:{}},r(e,e.exports),e.exports}var n="object";var t=function(r){return r&&r.Math==Math&&r};var v=t(typeof globalThis==n&&globalThis)||t(typeof window==n&&window)||t(typeof self==n&&self)||t(typeof r==n&&r)||Function("return this")();var a=function(r){try{return!!r()}catch(r){return true}};var d=!a(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7});var i={}.propertyIsEnumerable;var o=Object.getOwnPropertyDescriptor;var u=o&&!i.call({1:2},1);var f=u?function r(e){var n=o(this,e);return!!n&&n.enumerable}:i;var h={f:f};var c=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}};var l={}.toString;var s=function(r){return l.call(r).slice(8,-1)};var p="".split;var w=a(function(){return!Object("z").propertyIsEnumerable(0)})?function(r){return s(r)=="String"?p.call(r,""):Object(r)}:Object;var g=function(r){if(r==undefined)throw TypeError("Can't call method on "+r);return r};var y=function(r){return w(g(r))};var b=function(r){return typeof r==="object"?r!==null:typeof r==="function"};var m=function(r,e){if(!b(r))return r;var n,t;if(e&&typeof(n=r.toString)=="function"&&!b(t=n.call(r)))return t;if(typeof(n=r.valueOf)=="function"&&!b(t=n.call(r)))return t;if(!e&&typeof(n=r.toString)=="function"&&!b(t=n.call(r)))return t;throw TypeError("Can't convert object to primitive value")};var S={}.hasOwnProperty;var O=function(r,e){return S.call(r,e)};var j=v.document;var x=b(j)&&b(j.createElement);var E=function(r){return x?j.createElement(r):{}};var P=!d&&!a(function(){return Object.defineProperty(E("div"),"a",{get:function(){return 7}}).a!=7});var T=Object.getOwnPropertyDescriptor;var M=d?T:function r(e,n){e=y(e);n=m(n,true);if(P)try{return T(e,n)}catch(r){}if(O(e,n))return c(!h.f.call(e,n),e[n])};var A={f:M};var C=function(r){if(!b(r)){throw TypeError(String(r)+" is not an object")}return r};var k=Object.defineProperty;var L=d?k:function r(e,n,t){C(e);n=m(n,true);C(t);if(P)try{return k(e,n,t)}catch(r){}if("get"in t||"set"in t)throw TypeError("Accessors not supported");if("value"in t)e[n]=t.value;return e};var N={f:L};var _=d?function(r,e,n){return N.f(r,e,c(1,n))}:function(r,e,n){r[e]=n;return r};var F=function(e,n){try{_(v,e,n)}catch(r){v[e]=n}return n};var I=e(function(r){var e="__core-js_shared__";var n=v[e]||F(e,{});(r.exports=function(r,e){return n[r]||(n[r]=e!==undefined?e:{})})("versions",[]).push({version:"3.1.3",mode:"global",copyright:"© 2019 Denis Pushkarev (zloirock.ru)"})});var D=I("native-function-to-string",Function.toString);var W=v.WeakMap;var G=typeof W==="function"&&/native code/.test(D.call(W));var V=0;var q=Math.random();var z=function(r){return"Symbol("+String(r===undefined?"":r)+")_"+(++V+q).toString(36)};var H=I("keys");var R=function(r){return H[r]||(H[r]=z(r))};var K={};var Y=v.WeakMap;var B,J,Q;var U=function(r){return Q(r)?J(r):B(r,{})};var X=function(n){return function(r){var e;if(!b(r)||(e=J(r)).type!==n){throw TypeError("Incompatible receiver, "+n+" required")}return e}};if(G){var Z=new Y;var $=Z.get;var rr=Z.has;var er=Z.set;B=function(r,e){er.call(Z,r,e);return e};J=function(r){return $.call(Z,r)||{}};Q=function(r){return rr.call(Z,r)}}else{var nr=R("state");K[nr]=true;B=function(r,e){_(r,nr,e);return e};J=function(r){return O(r,nr)?r[nr]:{}};Q=function(r){return O(r,nr)}}var tr={set:B,get:J,has:Q,enforce:U,getterFor:X};var ar=e(function(r){var e=tr.get;var u=tr.enforce;var f=String(D).split("toString");I("inspectSource",function(r){return D.call(r)});(r.exports=function(r,e,n,t){var a=t?!!t.unsafe:false;var i=t?!!t.enumerable:false;var o=t?!!t.noTargetGet:false;if(typeof n=="function"){if(typeof e=="string"&&!O(n,"name"))_(n,"name",e);u(n).source=f.join(typeof e=="string"?e:"")}if(r===v){if(i)r[e]=n;else F(e,n);return}else if(!a){delete r[e]}else if(!o&&r[e]){i=true}if(i)r[e]=n;else _(r,e,n)})(Function.prototype,"toString",function r(){return typeof this=="function"&&e(this).source||D.call(this)})});var ir=v;var or=function(r){return typeof r=="function"?r:undefined};var ur=function(r,e){return arguments.length<2?or(ir[r])||or(v[r]):ir[r]&&ir[r][e]||v[r]&&v[r][e]};var fr=Math.ceil;var cr=Math.floor;var lr=function(r){return isNaN(r=+r)?0:(r>0?cr:fr)(r)};var vr=Math.min;var sr=function(r){return r>0?vr(lr(r),9007199254740991):0};var dr=Math.max;var hr=Math.min;var pr=function(r,e){var n=lr(r);return n<0?dr(n+e,0):hr(n,e)};var gr=function(u){return function(r,e,n){var t=y(r);var a=sr(t.length);var i=pr(n,a);var o;if(u&&e!=e)while(a>i){o=t[i++];if(o!=o)return true}else for(;a>i;i++){if((u||i in t)&&t[i]===e)return u||i||0}return!u&&-1}};var yr={includes:gr(true),indexOf:gr(false)};var br=yr.indexOf;var mr=function(r,e){var n=y(r);var t=0;var a=[];var i;for(i in n)!O(K,i)&&O(n,i)&&a.push(i);while(e.length>t)if(O(n,i=e[t++])){~br(a,i)||a.push(i)}return a};var wr=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"];var Sr=wr.concat("length","prototype");var Or=Object.getOwnPropertyNames||function r(e){return mr(e,Sr)};var jr={f:Or};var xr=Object.getOwnPropertySymbols;var Er={f:xr};var Pr=ur("Reflect","ownKeys")||function r(e){var n=jr.f(C(e));var t=Er.f;return t?n.concat(t(e)):n};var Tr=function(r,e){var n=Pr(e);var t=N.f;var a=A.f;for(var i=0;i<n.length;i++){var o=n[i];if(!O(r,o))t(r,o,a(e,o))}};var Mr=/#|\.prototype\./;var Ar=function(r,e){var n=kr[Cr(r)];return n==Nr?true:n==Lr?false:typeof e=="function"?a(e):!!e};var Cr=Ar.normalize=function(r){return String(r).replace(Mr,".").toLowerCase()};var kr=Ar.data={};var Lr=Ar.NATIVE="N";var Nr=Ar.POLYFILL="P";var _r=Ar;var Fr=A.f;var Ir=function(r,e){var n=r.target;var t=r.global;var a=r.stat;var i,o,u,f,c,l;if(t){o=v}else if(a){o=v[n]||F(n,{})}else{o=(v[n]||{}).prototype}if(o)for(u in e){c=e[u];if(r.noTargetGet){l=Fr(o,u);f=l&&l.value}else f=o[u];i=_r(t?u:n+(a?".":"#")+u,r.forced);if(!i&&f!==undefined){if(typeof c===typeof f)continue;Tr(c,f)}if(r.sham||f&&f.sham){_(c,"sham",true)}ar(o,u,c,r)}};var Dr=function(r){if(typeof r!="function"){throw TypeError(String(r)+" is not a function")}return r};var Wr=function(t,a,r){Dr(t);if(a===undefined)return t;switch(r){case 0:return function(){return t.call(a)};case 1:return function(r){return t.call(a,r)};case 2:return function(r,e){return t.call(a,r,e)};case 3:return function(r,e,n){return t.call(a,r,e,n)}}return function(){return t.apply(a,arguments)}};var Gr=function(r){return Object(g(r))};var Vr=Array.isArray||function r(e){return s(e)=="Array"};var qr=!!Object.getOwnPropertySymbols&&!a(function(){return!String(Symbol())});var zr=v.Symbol;var Hr=I("wks");var Rr=function(r){return Hr[r]||(Hr[r]=qr&&zr[r]||(qr?zr:z)("Symbol."+r))};var Kr=Rr("species");var Yr=function(r,e){var n;if(Vr(r)){n=r.constructor;if(typeof n=="function"&&(n===Array||Vr(n.prototype)))n=undefined;else if(b(n)){n=n[Kr];if(n===null)n=undefined}}return new(n===undefined?Array:n)(e===0?0:e)};var Br=[].push;var Jr=function(d){var h=d==1;var p=d==2;var g=d==3;var y=d==4;var b=d==6;var m=d==5||b;return function(r,e,n,t){var a=Gr(r);var i=w(a);var o=Wr(e,n,3);var u=sr(i.length);var f=0;var c=t||Yr;var l=h?c(r,u):p?c(r,0):undefined;var v,s;for(;u>f;f++)if(m||f in i){v=i[f];s=o(v,f,a);if(d){if(h)l[f]=s;else if(s)switch(d){case 3:return true;case 5:return v;case 6:return f;case 2:Br.call(l,v)}else if(y)return false}}return b?-1:g||y?y:l}};var Qr={forEach:Jr(0),map:Jr(1),filter:Jr(2),some:Jr(3),every:Jr(4),find:Jr(5),findIndex:Jr(6)};var Ur=Object.keys||function r(e){return mr(e,wr)};var Xr=d?Object.defineProperties:function r(e,n){C(e);var t=Ur(n);var a=t.length;var i=0;var o;while(a>i)N.f(e,o=t[i++],n[o]);return e};var Zr=ur("document","documentElement");var $r=R("IE_PROTO");var re="prototype";var ee=function(){};var ne=function(){var r=E("iframe");var e=wr.length;var n="<";var t="script";var a=">";var i="java"+t+":";var o;r.style.display="none";Zr.appendChild(r);r.src=String(i);o=r.contentWindow.document;o.open();o.write(n+t+a+"document.F=Object"+n+"/"+t+a);o.close();ne=o.F;while(e--)delete ne[re][wr[e]];return ne()};var te=Object.create||function r(e,n){var t;if(e!==null){ee[re]=C(e);t=new ee;ee[re]=null;t[$r]=e}else t=ne();return n===undefined?t:Xr(t,n)};K[$r]=true;var ae=Rr("unscopables");var ie=Array.prototype;if(ie[ae]==undefined){_(ie,ae,te(null))}var oe=function(r){ie[ae][r]=true};var ue=Qr.find;var fe="find";var ce=true;if(fe in[])Array(1)[fe](function(){ce=false});Ir({target:"Array",proto:true,forced:ce},{find:function r(e){return ue(this,e,arguments.length>1?arguments[1]:undefined)}});oe(fe);var le=yr.includes;Ir({target:"Array",proto:true},{includes:function r(e){return le(this,e,arguments.length>1?arguments[1]:undefined)}});oe("includes");var ve=Object.assign;var se=!ve||a(function(){var r={};var e={};var n=Symbol();var t="abcdefghijklmnopqrst";r[n]=7;t.split("").forEach(function(r){e[r]=r});return ve({},r)[n]!=7||Ur(ve({},e)).join("")!=t})?function r(e,n){var t=Gr(e);var a=arguments.length;var i=1;var o=Er.f;var u=h.f;while(a>i){var f=w(arguments[i++]);var c=o?Ur(f).concat(o(f)):Ur(f);var l=c.length;var v=0;var s;while(l>v){s=c[v++];if(!d||u.call(f,s))t[s]=f[s]}}return t}:ve;Ir({target:"Object",stat:true,forced:Object.assign!==se},{assign:se});var de=Rr("match");var he=function(r){var e;return b(r)&&((e=r[de])!==undefined?!!e:s(r)=="RegExp")};var pe=function(r){if(he(r)){throw TypeError("The method doesn't accept regular expressions")}return r};var ge=Rr("match");var ye=function(e){var n=/./;try{"/./"[e](n)}catch(r){try{n[ge]=false;return"/./"[e](n)}catch(r){}}return false};var be="".startsWith;var me=Math.min;Ir({target:"String",proto:true,forced:!ye("startsWith")},{startsWith:function r(e){var n=String(g(this));pe(e);var t=sr(me(arguments.length>1?arguments[1]:undefined,n.length));var a=String(e);return be?be.call(n,a,t):n.slice(t,t+a.length)===a}});if(typeof window!=="undefined"){(function(){var t=function(r,e){var n=r.nodeType;if(n===3){e.push(r.textContent.replace(/&/,"&").replace(/</,"<").replace(">",">"))}else if(n===1){e.push("<",r.tagName);if(r.hasAttributes()){[].forEach.call(r.attributes,function(r){e.push(" ",r.item.name,"='",r.item.value,"'")})}if(r.hasChildNodes()){e.push(">");[].forEach.call(r.childNodes,function(r){t(r,e)});e.push("</",r.tagName,">")}else{e.push("/>")}}else if(n==8){e.push("\x3c!--",r.nodeValue,"--\x3e")}};Object.defineProperty(SVGElement.prototype,"innerHTML",{get:function(){var r=[];var e=this.firstChild;while(e){t(e,r);e=e.nextSibling}return r.join("")},set:function(r){while(this.firstChild){this.removeChild(this.firstChild)}try{var e=new DOMParser;e.async=false;var n="<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>"+r+"</svg>";var t=e.parseFromString(n,"text/xml").documentElement;var a=t.firstChild;while(a){this.appendChild(this.ownerDocument.importNode(a,true));a=a.nextSibling}}catch(r){}}});Object.defineProperty(SVGElement.prototype,"innerSVG",{get:function(){return this.innerHTML},set:function(r){this.innerHTML=r}})})()}}); |
@@ -1,9 +0,7 @@ | ||
export {default as colorAdd} from "./src/add"; | ||
export {default as colorAssign} from "./src/assign"; | ||
export {default as colorContrast} from "./src/contrast"; | ||
export {default as colorDefaults} from "./src/defaults"; | ||
export {default as colorLegible} from "./src/legible"; | ||
export {default as colorLighter} from "./src/lighter"; | ||
export {default as colorSubtract} from "./src/subtract"; | ||
//# sourceMappingURL=index.js.map | ||
export { default as colorAdd } from "./src/add"; | ||
export { default as colorAssign } from "./src/assign"; | ||
export { default as colorContrast } from "./src/contrast"; | ||
export { default as colorDefaults } from "./src/defaults"; | ||
export { default as colorLegible } from "./src/legible"; | ||
export { default as colorLighter } from "./src/lighter"; | ||
export { default as colorSubtract } from "./src/subtract"; |
@@ -1,3 +0,2 @@ | ||
import {hsl} from "d3-color"; | ||
import { hsl } from "d3-color"; | ||
/** | ||
@@ -12,19 +11,14 @@ @function colorAdd | ||
*/ | ||
export default function(c1, c2, o1, o2) { | ||
if ( o1 === void 0 ) o1 = 1; | ||
if ( o2 === void 0 ) o2 = 1; | ||
export default function (c1, c2, o1 = 1, o2 = 1) { | ||
c1 = hsl(c1); | ||
c2 = hsl(c2); | ||
var d = Math.abs(c2.h * o2 - c1.h * o1); | ||
if (d > 180) { d -= 360; } | ||
var h = (Math.min(c1.h, c2.h) + d / 2) % 360; | ||
var l = c1.l + (c2.l * o2 - c1.l * o1) / 2, | ||
s = c1.s + (c2.s * o2 - c1.s * o1) / 2; | ||
// a = o1 + (o2 - o1) / 2; | ||
if (h < 0) { h += 360; } | ||
return hsl(("hsl(" + h + "," + (s * 100) + "%," + (l * 100) + "%)")).toString(); | ||
// return hsl(`hsl(${h},${s * 100}%,${l * 100}%,${a})`).toString(); | ||
} | ||
let d = Math.abs(c2.h * o2 - c1.h * o1); | ||
if (d > 180) d -= 360; | ||
let h = (Math.min(c1.h, c2.h) + d / 2) % 360; | ||
const l = c1.l + (c2.l * o2 - c1.l * o1) / 2, | ||
s = c1.s + (c2.s * o2 - c1.s * o1) / 2; // a = o1 + (o2 - o1) / 2; | ||
//# sourceMappingURL=add.js.map | ||
if (h < 0) h += 360; | ||
return hsl(`hsl(${h},${s * 100}%,${l * 100}%)`).toString(); // return hsl(`hsl(${h},${s * 100}%,${l * 100}%,${a})`).toString(); | ||
} |
@@ -1,4 +0,3 @@ | ||
import {color} from "d3-color"; | ||
import {getColor} from "./defaults"; | ||
import { color } from "d3-color"; | ||
import { getColor } from "./defaults"; | ||
/** | ||
@@ -11,21 +10,12 @@ @function colorAssign | ||
*/ | ||
export default function(c, u) { | ||
if ( u === void 0 ) u = {}; | ||
export default function (c, u = {}) { | ||
// If the value is null or undefined, set to grey. | ||
if ([null, void 0].indexOf(c) >= 0) { return getColor("missing", u); } | ||
// Else if the value is true, set to green. | ||
else if (c === true) { return getColor("on", u); } | ||
// Else if the value is false, set to red. | ||
else if (c === false) { return getColor("off", u); } | ||
if ([null, void 0].indexOf(c) >= 0) return getColor("missing", u); // Else if the value is true, set to green. | ||
else if (c === true) return getColor("on", u); // Else if the value is false, set to red. | ||
else if (c === false) return getColor("off", u); | ||
const p = color(c); // If the value is not a valid color string, use the color scale. | ||
var p = color(c); | ||
// If the value is not a valid color string, use the color scale. | ||
if (!p) { return getColor("scale", u)(c); } | ||
if (!p) return getColor("scale", u)(c); | ||
return c.toString(); | ||
} | ||
//# sourceMappingURL=assign.js.map | ||
} |
@@ -1,4 +0,3 @@ | ||
import {getColor} from "./defaults"; | ||
import {rgb} from "d3-color"; | ||
import { getColor } from "./defaults"; | ||
import { rgb } from "d3-color"; | ||
/** | ||
@@ -11,10 +10,7 @@ @function colorContrast | ||
*/ | ||
export default function(c, u) { | ||
if ( u === void 0 ) u = {}; | ||
export default function (c, u = {}) { | ||
c = rgb(c); | ||
var yiq = (c.r * 299 + c.g * 587 + c.b * 114) / 1000; | ||
const yiq = (c.r * 299 + c.g * 587 + c.b * 114) / 1000; | ||
return yiq >= 128 ? getColor("dark", u) : getColor("light", u); | ||
} | ||
//# sourceMappingURL=contrast.js.map | ||
} |
@@ -1,3 +0,2 @@ | ||
import {scaleOrdinal} from "d3-scale"; | ||
import { scaleOrdinal } from "d3-scale"; | ||
/** | ||
@@ -16,3 +15,4 @@ @namespace {Object} colorDefaults | ||
*/ | ||
var defaults = { | ||
const defaults = { | ||
dark: "#444444", | ||
@@ -23,9 +23,4 @@ light: "#f7f7f7", | ||
on: "#224f20", | ||
scale: scaleOrdinal().range([ | ||
"#b22200", "#282f6b", "#eace3f", "#b35c1e", "#224f20", "#5f487c", | ||
"#759143", "#419391", "#993c88", "#e89c89", "#ffee8d", "#afd5e8", | ||
"#f7ba77", "#a5c697", "#c5b5e5", "#d1d392", "#bbefd0", "#e099cf" | ||
]) | ||
scale: scaleOrdinal().range(["#b22200", "#282f6b", "#eace3f", "#b35c1e", "#224f20", "#5f487c", "#759143", "#419391", "#993c88", "#e89c89", "#ffee8d", "#afd5e8", "#f7ba77", "#a5c697", "#c5b5e5", "#d1d392", "#bbefd0", "#e099cf"]) | ||
}; | ||
/** | ||
@@ -36,10 +31,6 @@ Returns a color based on a key, whether it is present in a user supplied object or in the default object. | ||
*/ | ||
export function getColor(k, u) { | ||
if ( u === void 0 ) u = {}; | ||
export function getColor(k, u = {}) { | ||
return k in u ? u[k] : k in defaults ? defaults[k] : defaults.missing; | ||
} | ||
export default defaults; | ||
//# sourceMappingURL=defaults.js.map | ||
export default defaults; |
@@ -1,3 +0,2 @@ | ||
import {hsl} from "d3-color"; | ||
import { hsl } from "d3-color"; | ||
/** | ||
@@ -9,11 +8,12 @@ @function colorLegible | ||
*/ | ||
export default function(c) { | ||
export default function (c) { | ||
c = hsl(c); | ||
if (c.l > 0.45) { | ||
if (c.s > 0.8) { c.s = 0.8; } | ||
if (c.s > 0.8) c.s = 0.8; | ||
c.l = 0.45; | ||
} | ||
return c.toString(); | ||
} | ||
//# sourceMappingURL=legible.js.map | ||
} |
@@ -1,3 +0,2 @@ | ||
import {hsl} from "d3-color"; | ||
import { hsl } from "d3-color"; | ||
/** | ||
@@ -10,5 +9,4 @@ @function colorLighter | ||
*/ | ||
export default function(c, i) { | ||
if ( i === void 0 ) i = 0.5; | ||
export default function (c, i = 0.5) { | ||
c = hsl(c); | ||
@@ -19,4 +17,2 @@ i *= 1 - c.l; | ||
return c.toString(); | ||
} | ||
//# sourceMappingURL=lighter.js.map | ||
} |
@@ -1,3 +0,2 @@ | ||
import {hsl} from "d3-color"; | ||
import { hsl } from "d3-color"; | ||
/** | ||
@@ -12,19 +11,14 @@ @function colorSubtract | ||
*/ | ||
export default function(c1, c2, o1, o2) { | ||
if ( o1 === void 0 ) o1 = 1; | ||
if ( o2 === void 0 ) o2 = 1; | ||
export default function (c1, c2, o1 = 1, o2 = 1) { | ||
c1 = hsl(c1); | ||
c2 = hsl(c2); | ||
var d = c2.h * o2 - c1.h * o1; | ||
if (Math.abs(d) > 180) { d -= 360; } | ||
var h = (c1.h - d) % 360; | ||
var l = c1.l - (c2.l * o2 - c1.l * o1) / 2, | ||
s = c1.s - (c2.s * o2 - c1.s * o1) / 2; | ||
// a = o1 - (o2 - o1) / 2; | ||
if (h < 0) { h += 360; } | ||
return hsl(("hsl(" + h + "," + (s * 100) + "%," + (l * 100) + "%)")).toString(); | ||
// return hsl(`hsl(${h},${s * 100}%,${l * 100}%,${a})`).toString(); | ||
} | ||
let d = c2.h * o2 - c1.h * o1; | ||
if (Math.abs(d) > 180) d -= 360; | ||
let h = (c1.h - d) % 360; | ||
const l = c1.l - (c2.l * o2 - c1.l * o1) / 2, | ||
s = c1.s - (c2.s * o2 - c1.s * o1) / 2; // a = o1 - (o2 - o1) / 2; | ||
//# sourceMappingURL=subtract.js.map | ||
if (h < 0) h += 360; | ||
return hsl(`hsl(${h},${s * 100}%,${l * 100}%)`).toString(); // return hsl(`hsl(${h},${s * 100}%,${l * 100}%,${a})`).toString(); | ||
} |
{ | ||
"name": "d3plus-color", | ||
"version": "0.6.4", | ||
"version": "0.6.5", | ||
"description": "Color functions that extent the ability of d3-color.", | ||
@@ -26,5 +26,5 @@ "main": "build/d3plus-color.js", | ||
"dependencies": { | ||
"d3-color": "^1.2.3", | ||
"d3-color": "^1.2.8", | ||
"d3-scale": "^2.2.2", | ||
"d3plus-common": "^0.6.45" | ||
"d3plus-common": "^0.6.50" | ||
}, | ||
@@ -41,3 +41,3 @@ "scripts": { | ||
"devDependencies": { | ||
"d3plus-dev": "^0.6.17" | ||
"d3plus-dev": "^0.7.1" | ||
}, | ||
@@ -44,0 +44,0 @@ "module": "es/index", |
@@ -155,2 +155,2 @@ # d3plus-color | ||
###### <sub>Documentation generated on Tue, 12 Feb 2019 21:53:58 GMT</sub> | ||
###### <sub>Documentation generated on Wed, 03 Jul 2019 21:48:39 GMT</sub> |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses eval() which is a dangerous function. This prevents the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
76766
1073
14
3
Updatedd3-color@^1.2.8
Updatedd3plus-common@^0.6.50