book-source 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/StructuredDocument.js +1 -7
- package/lib/Style.js +7 -1
- package/lib/Theme.js +3 -2
- package/lib/book-source.js +5 -29
- package/package.json +8 -3
- package/css/code.css +0 -120
- package/css/core.css +0 -317
- package/css/standalone.css +0 -30
- package/css/unimplemented.css +0 -65
- package/extlib/chromajs.custom.js +0 -865
- package/lib/Color.js +0 -197
- package/lib/HtmlRenderer.js +0 -618
- package/lib/Palette.js +0 -313
|
@@ -1,865 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* chroma.js - JavaScript library for color conversions
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2011-2019, Gregor Aisch
|
|
5
|
-
* All rights reserved.
|
|
6
|
-
*
|
|
7
|
-
* Redistribution and use in source and binary forms, with or without
|
|
8
|
-
* modification, are permitted provided that the following conditions are met:
|
|
9
|
-
*
|
|
10
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
11
|
-
* list of conditions and the following disclaimer.
|
|
12
|
-
*
|
|
13
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
14
|
-
* this list of conditions and the following disclaimer in the documentation
|
|
15
|
-
* and/or other materials provided with the distribution.
|
|
16
|
-
*
|
|
17
|
-
* 3. The name Gregor Aisch may not be used to endorse or promote products
|
|
18
|
-
* derived from this software without specific prior written permission.
|
|
19
|
-
*
|
|
20
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
-
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
-
* DISCLAIMED. IN NO EVENT SHALL GREGOR AISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
|
24
|
-
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
25
|
-
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
26
|
-
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
27
|
-
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
28
|
-
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
29
|
-
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
30
|
-
*
|
|
31
|
-
* -------------------------------------------------------
|
|
32
|
-
*
|
|
33
|
-
* chroma.js includes colors from colorbrewer2.org, which are released under
|
|
34
|
-
* the following license:
|
|
35
|
-
*
|
|
36
|
-
* Copyright (c) 2002 Cynthia Brewer, Mark Harrower,
|
|
37
|
-
* and The Pennsylvania State University.
|
|
38
|
-
*
|
|
39
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
40
|
-
* you may not use this file except in compliance with the License.
|
|
41
|
-
* You may obtain a copy of the License at
|
|
42
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
43
|
-
*
|
|
44
|
-
* Unless required by applicable law or agreed to in writing,
|
|
45
|
-
* software distributed under the License is distributed on an
|
|
46
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
|
47
|
-
* either express or implied. See the License for the specific
|
|
48
|
-
* language governing permissions and limitations under the License.
|
|
49
|
-
*
|
|
50
|
-
* ------------------------------------------------------
|
|
51
|
-
*
|
|
52
|
-
* Named colors are taken from X11 Color Names.
|
|
53
|
-
* http://www.w3.org/TR/css3-color/#svg-color
|
|
54
|
-
*
|
|
55
|
-
* @preserve
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
(function (global, factory) {
|
|
59
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
60
|
-
typeof define === 'function' && define.amd ? define(factory) :
|
|
61
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.chroma = factory());
|
|
62
|
-
})(this, (function () { 'use strict';
|
|
63
|
-
|
|
64
|
-
var limit$1 = function (x, min, max) {
|
|
65
|
-
if ( min === void 0 ) min=0;
|
|
66
|
-
if ( max === void 0 ) max=1;
|
|
67
|
-
|
|
68
|
-
return x < min ? min : x > max ? max : x;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
var limit = limit$1;
|
|
72
|
-
|
|
73
|
-
var clip_rgb$1 = function (rgb) {
|
|
74
|
-
rgb._clipped = false;
|
|
75
|
-
rgb._unclipped = rgb.slice(0);
|
|
76
|
-
for (var i=0; i<=3; i++) {
|
|
77
|
-
if (i < 3) {
|
|
78
|
-
if (rgb[i] < 0 || rgb[i] > 255) { rgb._clipped = true; }
|
|
79
|
-
rgb[i] = limit(rgb[i], 0, 255);
|
|
80
|
-
} else if (i === 3) {
|
|
81
|
-
rgb[i] = limit(rgb[i], 0, 1);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return rgb;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
// ported from jQuery's $.type
|
|
88
|
-
var classToType = {};
|
|
89
|
-
for (var i = 0, list = ['Boolean', 'Number', 'String', 'Function', 'Array', 'Date', 'RegExp', 'Undefined', 'Null']; i < list.length; i += 1) {
|
|
90
|
-
var name = list[i];
|
|
91
|
-
|
|
92
|
-
classToType[("[object " + name + "]")] = name.toLowerCase();
|
|
93
|
-
}
|
|
94
|
-
var type$9 = function(obj) {
|
|
95
|
-
return classToType[Object.prototype.toString.call(obj)] || "object";
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
var type$8 = type$9;
|
|
99
|
-
|
|
100
|
-
var unpack$a = function (args, keyOrder) {
|
|
101
|
-
if ( keyOrder === void 0 ) keyOrder=null;
|
|
102
|
-
|
|
103
|
-
// if called with more than 3 arguments, we return the arguments
|
|
104
|
-
if (args.length >= 3) { return Array.prototype.slice.call(args); }
|
|
105
|
-
// with less than 3 args we check if first arg is object
|
|
106
|
-
// and use the keyOrder string to extract and sort properties
|
|
107
|
-
if (type$8(args[0]) == 'object' && keyOrder) {
|
|
108
|
-
return keyOrder.split('')
|
|
109
|
-
.filter(function (k) { return args[0][k] !== undefined; })
|
|
110
|
-
.map(function (k) { return args[0][k]; });
|
|
111
|
-
}
|
|
112
|
-
// otherwise we just return the first argument
|
|
113
|
-
// (which we suppose is an array of args)
|
|
114
|
-
return args[0];
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
var type$7 = type$9;
|
|
118
|
-
|
|
119
|
-
var last$2 = function (args) {
|
|
120
|
-
if (args.length < 2) { return null; }
|
|
121
|
-
var l = args.length-1;
|
|
122
|
-
if (type$7(args[l]) == 'string') { return args[l].toLowerCase(); }
|
|
123
|
-
return null;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
var PI = Math.PI;
|
|
127
|
-
|
|
128
|
-
var utils = {
|
|
129
|
-
clip_rgb: clip_rgb$1,
|
|
130
|
-
limit: limit$1,
|
|
131
|
-
type: type$9,
|
|
132
|
-
unpack: unpack$a,
|
|
133
|
-
last: last$2,
|
|
134
|
-
PI: PI,
|
|
135
|
-
TWOPI: PI*2,
|
|
136
|
-
PITHIRD: PI/3,
|
|
137
|
-
DEG2RAD: PI / 180,
|
|
138
|
-
RAD2DEG: 180 / PI
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
var input$3 = {
|
|
142
|
-
format: {},
|
|
143
|
-
autodetect: []
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
var last$1 = utils.last;
|
|
147
|
-
var clip_rgb = utils.clip_rgb;
|
|
148
|
-
var type$6 = utils.type;
|
|
149
|
-
var _input = input$3;
|
|
150
|
-
|
|
151
|
-
var Color$b = function Color() {
|
|
152
|
-
var args = [], len = arguments.length;
|
|
153
|
-
while ( len-- ) args[ len ] = arguments[ len ];
|
|
154
|
-
|
|
155
|
-
var me = this;
|
|
156
|
-
if (type$6(args[0]) === 'object' &&
|
|
157
|
-
args[0].constructor &&
|
|
158
|
-
args[0].constructor === this.constructor) {
|
|
159
|
-
// the argument is already a Color instance
|
|
160
|
-
return args[0];
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// last argument could be the mode
|
|
164
|
-
var mode = last$1(args);
|
|
165
|
-
var autodetect = false;
|
|
166
|
-
|
|
167
|
-
if (!mode) {
|
|
168
|
-
autodetect = true;
|
|
169
|
-
if (!_input.sorted) {
|
|
170
|
-
_input.autodetect = _input.autodetect.sort(function (a,b) { return b.p - a.p; });
|
|
171
|
-
_input.sorted = true;
|
|
172
|
-
}
|
|
173
|
-
// auto-detect format
|
|
174
|
-
for (var i = 0, list = _input.autodetect; i < list.length; i += 1) {
|
|
175
|
-
var chk = list[i];
|
|
176
|
-
|
|
177
|
-
mode = chk.test.apply(chk, args);
|
|
178
|
-
if (mode) { break; }
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
if (_input.format[mode]) {
|
|
183
|
-
var rgb = _input.format[mode].apply(null, autodetect ? args : args.slice(0,-1));
|
|
184
|
-
me._rgb = clip_rgb(rgb);
|
|
185
|
-
} else {
|
|
186
|
-
throw new Error('unknown format: '+args);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// add alpha channel
|
|
190
|
-
if (me._rgb.length === 3) { me._rgb.push(1); }
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
Color$b.prototype.toString = function toString () {
|
|
194
|
-
if (type$6(this.hex) == 'function') { return this.hex(); }
|
|
195
|
-
return ("[" + (this._rgb.join(',')) + "]");
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
var Color_1 = Color$b;
|
|
199
|
-
|
|
200
|
-
var chroma$4 = function () {
|
|
201
|
-
var args = [], len = arguments.length;
|
|
202
|
-
while ( len-- ) args[ len ] = arguments[ len ];
|
|
203
|
-
|
|
204
|
-
return new (Function.prototype.bind.apply( chroma$4.Color, [ null ].concat( args) ));
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
chroma$4.Color = Color_1;
|
|
208
|
-
chroma$4.version = '2.6.2';
|
|
209
|
-
|
|
210
|
-
var chroma_1 = chroma$4;
|
|
211
|
-
|
|
212
|
-
var unpack$9 = utils.unpack;
|
|
213
|
-
var last = utils.last;
|
|
214
|
-
var round$2 = Math.round;
|
|
215
|
-
|
|
216
|
-
var rgb2hex$1 = function () {
|
|
217
|
-
var args = [], len = arguments.length;
|
|
218
|
-
while ( len-- ) args[ len ] = arguments[ len ];
|
|
219
|
-
|
|
220
|
-
var ref = unpack$9(args, 'rgba');
|
|
221
|
-
var r = ref[0];
|
|
222
|
-
var g = ref[1];
|
|
223
|
-
var b = ref[2];
|
|
224
|
-
var a = ref[3];
|
|
225
|
-
var mode = last(args) || 'auto';
|
|
226
|
-
if (a === undefined) { a = 1; }
|
|
227
|
-
if (mode === 'auto') {
|
|
228
|
-
mode = a < 1 ? 'rgba' : 'rgb';
|
|
229
|
-
}
|
|
230
|
-
r = round$2(r);
|
|
231
|
-
g = round$2(g);
|
|
232
|
-
b = round$2(b);
|
|
233
|
-
var u = r << 16 | g << 8 | b;
|
|
234
|
-
var str = "000000" + u.toString(16); //#.toUpperCase();
|
|
235
|
-
str = str.substr(str.length - 6);
|
|
236
|
-
var hxa = '0' + round$2(a * 255).toString(16);
|
|
237
|
-
hxa = hxa.substr(hxa.length - 2);
|
|
238
|
-
switch (mode.toLowerCase()) {
|
|
239
|
-
case 'rgba': return ("#" + str + hxa);
|
|
240
|
-
case 'argb': return ("#" + hxa + str);
|
|
241
|
-
default: return ("#" + str);
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
var rgb2hex_1 = rgb2hex$1;
|
|
246
|
-
|
|
247
|
-
var RE_HEX = /^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
|
|
248
|
-
var RE_HEXA = /^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/;
|
|
249
|
-
|
|
250
|
-
var hex2rgb = function (hex) {
|
|
251
|
-
if (hex.match(RE_HEX)) {
|
|
252
|
-
// remove optional leading #
|
|
253
|
-
if (hex.length === 4 || hex.length === 7) {
|
|
254
|
-
hex = hex.substr(1);
|
|
255
|
-
}
|
|
256
|
-
// expand short-notation to full six-digit
|
|
257
|
-
if (hex.length === 3) {
|
|
258
|
-
hex = hex.split('');
|
|
259
|
-
hex = hex[0]+hex[0]+hex[1]+hex[1]+hex[2]+hex[2];
|
|
260
|
-
}
|
|
261
|
-
var u = parseInt(hex, 16);
|
|
262
|
-
var r = u >> 16;
|
|
263
|
-
var g = u >> 8 & 0xFF;
|
|
264
|
-
var b = u & 0xFF;
|
|
265
|
-
return [r,g,b,1];
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
// match rgba hex format, eg #FF000077
|
|
269
|
-
if (hex.match(RE_HEXA)) {
|
|
270
|
-
if (hex.length === 5 || hex.length === 9) {
|
|
271
|
-
// remove optional leading #
|
|
272
|
-
hex = hex.substr(1);
|
|
273
|
-
}
|
|
274
|
-
// expand short-notation to full eight-digit
|
|
275
|
-
if (hex.length === 4) {
|
|
276
|
-
hex = hex.split('');
|
|
277
|
-
hex = hex[0]+hex[0]+hex[1]+hex[1]+hex[2]+hex[2]+hex[3]+hex[3];
|
|
278
|
-
}
|
|
279
|
-
var u$1 = parseInt(hex, 16);
|
|
280
|
-
var r$1 = u$1 >> 24 & 0xFF;
|
|
281
|
-
var g$1 = u$1 >> 16 & 0xFF;
|
|
282
|
-
var b$1 = u$1 >> 8 & 0xFF;
|
|
283
|
-
var a = Math.round((u$1 & 0xFF) / 0xFF * 100) / 100;
|
|
284
|
-
return [r$1,g$1,b$1,a];
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
// we used to check for css colors here
|
|
288
|
-
// if _input.css? and rgb = _input.css hex
|
|
289
|
-
// return rgb
|
|
290
|
-
|
|
291
|
-
throw new Error(("unknown hex color: " + hex));
|
|
292
|
-
};
|
|
293
|
-
|
|
294
|
-
var hex2rgb_1 = hex2rgb;
|
|
295
|
-
|
|
296
|
-
var chroma$3 = chroma_1;
|
|
297
|
-
var Color$a = Color_1;
|
|
298
|
-
var type$5 = utils.type;
|
|
299
|
-
var input$2 = input$3;
|
|
300
|
-
|
|
301
|
-
var rgb2hex = rgb2hex_1;
|
|
302
|
-
|
|
303
|
-
Color$a.prototype.hex = function(mode) {
|
|
304
|
-
return rgb2hex(this._rgb, mode);
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
chroma$3.hex = function () {
|
|
308
|
-
var args = [], len = arguments.length;
|
|
309
|
-
while ( len-- ) args[ len ] = arguments[ len ];
|
|
310
|
-
|
|
311
|
-
return new (Function.prototype.bind.apply( Color$a, [ null ].concat( args, ['hex']) ));
|
|
312
|
-
};
|
|
313
|
-
|
|
314
|
-
input$2.format.hex = hex2rgb_1;
|
|
315
|
-
input$2.autodetect.push({
|
|
316
|
-
p: 4,
|
|
317
|
-
test: function (h) {
|
|
318
|
-
var rest = [], len = arguments.length - 1;
|
|
319
|
-
while ( len-- > 0 ) rest[ len ] = arguments[ len + 1 ];
|
|
320
|
-
|
|
321
|
-
if (!rest.length && type$5(h) === 'string' && [3,4,5,6,7,8,9].indexOf(h.length) >= 0) {
|
|
322
|
-
return 'hex';
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
var labConstants = {
|
|
328
|
-
// Corresponds roughly to RGB brighter/darker
|
|
329
|
-
Kn: 18,
|
|
330
|
-
|
|
331
|
-
// D65 standard referent
|
|
332
|
-
Xn: 0.950470,
|
|
333
|
-
Yn: 1,
|
|
334
|
-
Zn: 1.088830,
|
|
335
|
-
|
|
336
|
-
t0: 0.137931034, // 4 / 29
|
|
337
|
-
t1: 0.206896552, // 6 / 29
|
|
338
|
-
t2: 0.12841855, // 3 * t1 * t1
|
|
339
|
-
t3: 0.008856452, // t1 * t1 * t1
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
var LAB_CONSTANTS$1 = labConstants;
|
|
343
|
-
var unpack$8 = utils.unpack;
|
|
344
|
-
var pow$1 = Math.pow;
|
|
345
|
-
|
|
346
|
-
var rgb2lab$1 = function () {
|
|
347
|
-
var args = [], len = arguments.length;
|
|
348
|
-
while ( len-- ) args[ len ] = arguments[ len ];
|
|
349
|
-
|
|
350
|
-
var ref = unpack$8(args, 'rgb');
|
|
351
|
-
var r = ref[0];
|
|
352
|
-
var g = ref[1];
|
|
353
|
-
var b = ref[2];
|
|
354
|
-
var ref$1 = rgb2xyz(r,g,b);
|
|
355
|
-
var x = ref$1[0];
|
|
356
|
-
var y = ref$1[1];
|
|
357
|
-
var z = ref$1[2];
|
|
358
|
-
var l = 116 * y - 16;
|
|
359
|
-
return [l < 0 ? 0 : l, 500 * (x - y), 200 * (y - z)];
|
|
360
|
-
};
|
|
361
|
-
|
|
362
|
-
var rgb_xyz = function (r) {
|
|
363
|
-
if ((r /= 255) <= 0.04045) { return r / 12.92; }
|
|
364
|
-
return pow$1((r + 0.055) / 1.055, 2.4);
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
var xyz_lab = function (t) {
|
|
368
|
-
if (t > LAB_CONSTANTS$1.t3) { return pow$1(t, 1 / 3); }
|
|
369
|
-
return t / LAB_CONSTANTS$1.t2 + LAB_CONSTANTS$1.t0;
|
|
370
|
-
};
|
|
371
|
-
|
|
372
|
-
var rgb2xyz = function (r,g,b) {
|
|
373
|
-
r = rgb_xyz(r);
|
|
374
|
-
g = rgb_xyz(g);
|
|
375
|
-
b = rgb_xyz(b);
|
|
376
|
-
var x = xyz_lab((0.4124564 * r + 0.3575761 * g + 0.1804375 * b) / LAB_CONSTANTS$1.Xn);
|
|
377
|
-
var y = xyz_lab((0.2126729 * r + 0.7151522 * g + 0.0721750 * b) / LAB_CONSTANTS$1.Yn);
|
|
378
|
-
var z = xyz_lab((0.0193339 * r + 0.1191920 * g + 0.9503041 * b) / LAB_CONSTANTS$1.Zn);
|
|
379
|
-
return [x,y,z];
|
|
380
|
-
};
|
|
381
|
-
|
|
382
|
-
var rgb2lab_1 = rgb2lab$1;
|
|
383
|
-
|
|
384
|
-
var unpack$7 = utils.unpack;
|
|
385
|
-
var RAD2DEG = utils.RAD2DEG;
|
|
386
|
-
var sqrt = Math.sqrt;
|
|
387
|
-
var atan2 = Math.atan2;
|
|
388
|
-
var round$1 = Math.round;
|
|
389
|
-
|
|
390
|
-
var lab2lch$1 = function () {
|
|
391
|
-
var args = [], len = arguments.length;
|
|
392
|
-
while ( len-- ) args[ len ] = arguments[ len ];
|
|
393
|
-
|
|
394
|
-
var ref = unpack$7(args, 'lab');
|
|
395
|
-
var l = ref[0];
|
|
396
|
-
var a = ref[1];
|
|
397
|
-
var b = ref[2];
|
|
398
|
-
var c = sqrt(a * a + b * b);
|
|
399
|
-
var h = (atan2(b, a) * RAD2DEG + 360) % 360;
|
|
400
|
-
if (round$1(c*10000) === 0) { h = Number.NaN; }
|
|
401
|
-
return [l, c, h];
|
|
402
|
-
};
|
|
403
|
-
|
|
404
|
-
var lab2lch_1 = lab2lch$1;
|
|
405
|
-
|
|
406
|
-
var unpack$6 = utils.unpack;
|
|
407
|
-
var rgb2lab = rgb2lab_1;
|
|
408
|
-
var lab2lch = lab2lch_1;
|
|
409
|
-
|
|
410
|
-
var rgb2lch$1 = function () {
|
|
411
|
-
var args = [], len = arguments.length;
|
|
412
|
-
while ( len-- ) args[ len ] = arguments[ len ];
|
|
413
|
-
|
|
414
|
-
var ref = unpack$6(args, 'rgb');
|
|
415
|
-
var r = ref[0];
|
|
416
|
-
var g = ref[1];
|
|
417
|
-
var b = ref[2];
|
|
418
|
-
var ref$1 = rgb2lab(r,g,b);
|
|
419
|
-
var l = ref$1[0];
|
|
420
|
-
var a = ref$1[1];
|
|
421
|
-
var b_ = ref$1[2];
|
|
422
|
-
return lab2lch(l,a,b_);
|
|
423
|
-
};
|
|
424
|
-
|
|
425
|
-
var rgb2lch_1 = rgb2lch$1;
|
|
426
|
-
|
|
427
|
-
var unpack$5 = utils.unpack;
|
|
428
|
-
var DEG2RAD = utils.DEG2RAD;
|
|
429
|
-
var sin = Math.sin;
|
|
430
|
-
var cos = Math.cos;
|
|
431
|
-
|
|
432
|
-
var lch2lab$1 = function () {
|
|
433
|
-
var args = [], len = arguments.length;
|
|
434
|
-
while ( len-- ) args[ len ] = arguments[ len ];
|
|
435
|
-
|
|
436
|
-
/*
|
|
437
|
-
Convert from a qualitative parameter h and a quantitative parameter l to a 24-bit pixel.
|
|
438
|
-
These formulas were invented by David Dalrymple to obtain maximum contrast without going
|
|
439
|
-
out of gamut if the parameters are in the range 0-1.
|
|
440
|
-
|
|
441
|
-
A saturation multiplier was added by Gregor Aisch
|
|
442
|
-
*/
|
|
443
|
-
var ref = unpack$5(args, 'lch');
|
|
444
|
-
var l = ref[0];
|
|
445
|
-
var c = ref[1];
|
|
446
|
-
var h = ref[2];
|
|
447
|
-
if (isNaN(h)) { h = 0; }
|
|
448
|
-
h = h * DEG2RAD;
|
|
449
|
-
return [l, cos(h) * c, sin(h) * c]
|
|
450
|
-
};
|
|
451
|
-
|
|
452
|
-
var lch2lab_1 = lch2lab$1;
|
|
453
|
-
|
|
454
|
-
var LAB_CONSTANTS = labConstants;
|
|
455
|
-
var unpack$4 = utils.unpack;
|
|
456
|
-
var pow = Math.pow;
|
|
457
|
-
|
|
458
|
-
/*
|
|
459
|
-
* L* [0..100]
|
|
460
|
-
* a [-100..100]
|
|
461
|
-
* b [-100..100]
|
|
462
|
-
*/
|
|
463
|
-
var lab2rgb$1 = function () {
|
|
464
|
-
var args = [], len = arguments.length;
|
|
465
|
-
while ( len-- ) args[ len ] = arguments[ len ];
|
|
466
|
-
|
|
467
|
-
args = unpack$4(args, 'lab');
|
|
468
|
-
var l = args[0];
|
|
469
|
-
var a = args[1];
|
|
470
|
-
var b = args[2];
|
|
471
|
-
var x,y,z, r,g,b_;
|
|
472
|
-
|
|
473
|
-
y = (l + 16) / 116;
|
|
474
|
-
x = isNaN(a) ? y : y + a / 500;
|
|
475
|
-
z = isNaN(b) ? y : y - b / 200;
|
|
476
|
-
|
|
477
|
-
y = LAB_CONSTANTS.Yn * lab_xyz(y);
|
|
478
|
-
x = LAB_CONSTANTS.Xn * lab_xyz(x);
|
|
479
|
-
z = LAB_CONSTANTS.Zn * lab_xyz(z);
|
|
480
|
-
|
|
481
|
-
r = xyz_rgb(3.2404542 * x - 1.5371385 * y - 0.4985314 * z); // D65 -> sRGB
|
|
482
|
-
g = xyz_rgb(-0.9692660 * x + 1.8760108 * y + 0.0415560 * z);
|
|
483
|
-
b_ = xyz_rgb(0.0556434 * x - 0.2040259 * y + 1.0572252 * z);
|
|
484
|
-
|
|
485
|
-
return [r,g,b_,args.length > 3 ? args[3] : 1];
|
|
486
|
-
};
|
|
487
|
-
|
|
488
|
-
var xyz_rgb = function (r) {
|
|
489
|
-
return 255 * (r <= 0.00304 ? 12.92 * r : 1.055 * pow(r, 1 / 2.4) - 0.055)
|
|
490
|
-
};
|
|
491
|
-
|
|
492
|
-
var lab_xyz = function (t) {
|
|
493
|
-
return t > LAB_CONSTANTS.t1 ? t * t * t : LAB_CONSTANTS.t2 * (t - LAB_CONSTANTS.t0)
|
|
494
|
-
};
|
|
495
|
-
|
|
496
|
-
var lab2rgb_1 = lab2rgb$1;
|
|
497
|
-
|
|
498
|
-
var unpack$3 = utils.unpack;
|
|
499
|
-
var lch2lab = lch2lab_1;
|
|
500
|
-
var lab2rgb = lab2rgb_1;
|
|
501
|
-
|
|
502
|
-
var lch2rgb$1 = function () {
|
|
503
|
-
var args = [], len = arguments.length;
|
|
504
|
-
while ( len-- ) args[ len ] = arguments[ len ];
|
|
505
|
-
|
|
506
|
-
args = unpack$3(args, 'lch');
|
|
507
|
-
var l = args[0];
|
|
508
|
-
var c = args[1];
|
|
509
|
-
var h = args[2];
|
|
510
|
-
var ref = lch2lab (l,c,h);
|
|
511
|
-
var L = ref[0];
|
|
512
|
-
var a = ref[1];
|
|
513
|
-
var b_ = ref[2];
|
|
514
|
-
var ref$1 = lab2rgb (L,a,b_);
|
|
515
|
-
var r = ref$1[0];
|
|
516
|
-
var g = ref$1[1];
|
|
517
|
-
var b = ref$1[2];
|
|
518
|
-
return [r, g, b, args.length > 3 ? args[3] : 1];
|
|
519
|
-
};
|
|
520
|
-
|
|
521
|
-
var lch2rgb_1 = lch2rgb$1;
|
|
522
|
-
|
|
523
|
-
var unpack$2 = utils.unpack;
|
|
524
|
-
var lch2rgb = lch2rgb_1;
|
|
525
|
-
|
|
526
|
-
var hcl2rgb = function () {
|
|
527
|
-
var args = [], len = arguments.length;
|
|
528
|
-
while ( len-- ) args[ len ] = arguments[ len ];
|
|
529
|
-
|
|
530
|
-
var hcl = unpack$2(args, 'hcl').reverse();
|
|
531
|
-
return lch2rgb.apply(void 0, hcl);
|
|
532
|
-
};
|
|
533
|
-
|
|
534
|
-
var hcl2rgb_1 = hcl2rgb;
|
|
535
|
-
|
|
536
|
-
var unpack$1 = utils.unpack;
|
|
537
|
-
var type$4 = utils.type;
|
|
538
|
-
var chroma$2 = chroma_1;
|
|
539
|
-
var Color$9 = Color_1;
|
|
540
|
-
var input$1 = input$3;
|
|
541
|
-
|
|
542
|
-
var rgb2lch = rgb2lch_1;
|
|
543
|
-
|
|
544
|
-
Color$9.prototype.lch = function() { return rgb2lch(this._rgb); };
|
|
545
|
-
Color$9.prototype.hcl = function() { return rgb2lch(this._rgb).reverse(); };
|
|
546
|
-
|
|
547
|
-
chroma$2.lch = function () {
|
|
548
|
-
var args = [], len = arguments.length;
|
|
549
|
-
while ( len-- ) args[ len ] = arguments[ len ];
|
|
550
|
-
|
|
551
|
-
return new (Function.prototype.bind.apply( Color$9, [ null ].concat( args, ['lch']) ));
|
|
552
|
-
};
|
|
553
|
-
chroma$2.hcl = function () {
|
|
554
|
-
var args = [], len = arguments.length;
|
|
555
|
-
while ( len-- ) args[ len ] = arguments[ len ];
|
|
556
|
-
|
|
557
|
-
return new (Function.prototype.bind.apply( Color$9, [ null ].concat( args, ['hcl']) ));
|
|
558
|
-
};
|
|
559
|
-
|
|
560
|
-
input$1.format.lch = lch2rgb_1;
|
|
561
|
-
input$1.format.hcl = hcl2rgb_1;
|
|
562
|
-
|
|
563
|
-
['lch','hcl'].forEach(function (m) { return input$1.autodetect.push({
|
|
564
|
-
p: 2,
|
|
565
|
-
test: function () {
|
|
566
|
-
var args = [], len = arguments.length;
|
|
567
|
-
while ( len-- ) args[ len ] = arguments[ len ];
|
|
568
|
-
|
|
569
|
-
args = unpack$1(args, m);
|
|
570
|
-
if (type$4(args) === 'array' && args.length === 3) {
|
|
571
|
-
return m;
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
}); });
|
|
575
|
-
|
|
576
|
-
var chroma$1 = chroma_1;
|
|
577
|
-
var Color$8 = Color_1;
|
|
578
|
-
var input = input$3;
|
|
579
|
-
var unpack = utils.unpack;
|
|
580
|
-
var type$3 = utils.type;
|
|
581
|
-
var round = Math.round;
|
|
582
|
-
|
|
583
|
-
Color$8.prototype.rgb = function(rnd) {
|
|
584
|
-
if ( rnd === void 0 ) rnd=true;
|
|
585
|
-
|
|
586
|
-
if (rnd === false) { return this._rgb.slice(0,3); }
|
|
587
|
-
return this._rgb.slice(0,3).map(round);
|
|
588
|
-
};
|
|
589
|
-
|
|
590
|
-
Color$8.prototype.rgba = function(rnd) {
|
|
591
|
-
if ( rnd === void 0 ) rnd=true;
|
|
592
|
-
|
|
593
|
-
return this._rgb.slice(0,4).map(function (v,i) {
|
|
594
|
-
return i<3 ? (rnd === false ? v : round(v)) : v;
|
|
595
|
-
});
|
|
596
|
-
};
|
|
597
|
-
|
|
598
|
-
chroma$1.rgb = function () {
|
|
599
|
-
var args = [], len = arguments.length;
|
|
600
|
-
while ( len-- ) args[ len ] = arguments[ len ];
|
|
601
|
-
|
|
602
|
-
return new (Function.prototype.bind.apply( Color$8, [ null ].concat( args, ['rgb']) ));
|
|
603
|
-
};
|
|
604
|
-
|
|
605
|
-
input.format.rgb = function () {
|
|
606
|
-
var args = [], len = arguments.length;
|
|
607
|
-
while ( len-- ) args[ len ] = arguments[ len ];
|
|
608
|
-
|
|
609
|
-
var rgba = unpack(args, 'rgba');
|
|
610
|
-
if (rgba[3] === undefined) { rgba[3] = 1; }
|
|
611
|
-
return rgba;
|
|
612
|
-
};
|
|
613
|
-
|
|
614
|
-
input.autodetect.push({
|
|
615
|
-
p: 3,
|
|
616
|
-
test: function () {
|
|
617
|
-
var args = [], len = arguments.length;
|
|
618
|
-
while ( len-- ) args[ len ] = arguments[ len ];
|
|
619
|
-
|
|
620
|
-
args = unpack(args, 'rgba');
|
|
621
|
-
if (type$3(args) === 'array' && (args.length === 3 ||
|
|
622
|
-
args.length === 4 && type$3(args[3]) == 'number' && args[3] >= 0 && args[3] <= 1)) {
|
|
623
|
-
return 'rgb';
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
});
|
|
627
|
-
|
|
628
|
-
var Color$7 = Color_1;
|
|
629
|
-
var type$2 = utils.type;
|
|
630
|
-
|
|
631
|
-
Color$7.prototype.alpha = function(a, mutate) {
|
|
632
|
-
if ( mutate === void 0 ) mutate=false;
|
|
633
|
-
|
|
634
|
-
if (a !== undefined && type$2(a) === 'number') {
|
|
635
|
-
if (mutate) {
|
|
636
|
-
this._rgb[3] = a;
|
|
637
|
-
return this;
|
|
638
|
-
}
|
|
639
|
-
return new Color$7([this._rgb[0], this._rgb[1], this._rgb[2], a], 'rgb');
|
|
640
|
-
}
|
|
641
|
-
return this._rgb[3];
|
|
642
|
-
};
|
|
643
|
-
|
|
644
|
-
var Color$6 = Color_1;
|
|
645
|
-
|
|
646
|
-
Color$6.prototype.clipped = function() {
|
|
647
|
-
return this._rgb._clipped || false;
|
|
648
|
-
};
|
|
649
|
-
|
|
650
|
-
var Color$5 = Color_1;
|
|
651
|
-
|
|
652
|
-
Color$5.prototype.get = function (mc) {
|
|
653
|
-
var ref = mc.split('.');
|
|
654
|
-
var mode = ref[0];
|
|
655
|
-
var channel = ref[1];
|
|
656
|
-
var src = this[mode]();
|
|
657
|
-
if (channel) {
|
|
658
|
-
var i = mode.indexOf(channel) - (mode.substr(0, 2) === 'ok' ? 2 : 0);
|
|
659
|
-
if (i > -1) { return src[i]; }
|
|
660
|
-
throw new Error(("unknown channel " + channel + " in mode " + mode));
|
|
661
|
-
} else {
|
|
662
|
-
return src;
|
|
663
|
-
}
|
|
664
|
-
};
|
|
665
|
-
|
|
666
|
-
var interpolator$1 = {};
|
|
667
|
-
|
|
668
|
-
var Color$4 = Color_1;
|
|
669
|
-
var type$1 = utils.type;
|
|
670
|
-
var interpolator = interpolator$1;
|
|
671
|
-
|
|
672
|
-
var mix$1 = function (col1, col2, f) {
|
|
673
|
-
if ( f === void 0 ) f=0.5;
|
|
674
|
-
var rest = [], len = arguments.length - 3;
|
|
675
|
-
while ( len-- > 0 ) rest[ len ] = arguments[ len + 3 ];
|
|
676
|
-
|
|
677
|
-
var mode = rest[0] || 'lrgb';
|
|
678
|
-
if (!interpolator[mode] && !rest.length) {
|
|
679
|
-
// fall back to the first supported mode
|
|
680
|
-
mode = Object.keys(interpolator)[0];
|
|
681
|
-
}
|
|
682
|
-
if (!interpolator[mode]) {
|
|
683
|
-
throw new Error(("interpolation mode " + mode + " is not defined"));
|
|
684
|
-
}
|
|
685
|
-
if (type$1(col1) !== 'object') { col1 = new Color$4(col1); }
|
|
686
|
-
if (type$1(col2) !== 'object') { col2 = new Color$4(col2); }
|
|
687
|
-
return interpolator[mode](col1, col2, f)
|
|
688
|
-
.alpha(col1.alpha() + f * (col2.alpha() - col1.alpha()));
|
|
689
|
-
};
|
|
690
|
-
|
|
691
|
-
var Color$3 = Color_1;
|
|
692
|
-
var mix = mix$1;
|
|
693
|
-
|
|
694
|
-
Color$3.prototype.mix =
|
|
695
|
-
Color$3.prototype.interpolate = function(col2, f) {
|
|
696
|
-
if ( f === void 0 ) f=0.5;
|
|
697
|
-
var rest = [], len = arguments.length - 2;
|
|
698
|
-
while ( len-- > 0 ) rest[ len ] = arguments[ len + 2 ];
|
|
699
|
-
|
|
700
|
-
return mix.apply(void 0, [ this, col2, f ].concat( rest ));
|
|
701
|
-
};
|
|
702
|
-
|
|
703
|
-
var Color$2 = Color_1;
|
|
704
|
-
var type = utils.type;
|
|
705
|
-
|
|
706
|
-
Color$2.prototype.set = function (mc, value, mutate) {
|
|
707
|
-
if ( mutate === void 0 ) mutate = false;
|
|
708
|
-
|
|
709
|
-
var ref = mc.split('.');
|
|
710
|
-
var mode = ref[0];
|
|
711
|
-
var channel = ref[1];
|
|
712
|
-
var src = this[mode]();
|
|
713
|
-
if (channel) {
|
|
714
|
-
var i = mode.indexOf(channel) - (mode.substr(0, 2) === 'ok' ? 2 : 0);
|
|
715
|
-
if (i > -1) {
|
|
716
|
-
if (type(value) == 'string') {
|
|
717
|
-
switch (value.charAt(0)) {
|
|
718
|
-
case '+':
|
|
719
|
-
src[i] += +value;
|
|
720
|
-
break;
|
|
721
|
-
case '-':
|
|
722
|
-
src[i] += +value;
|
|
723
|
-
break;
|
|
724
|
-
case '*':
|
|
725
|
-
src[i] *= +value.substr(1);
|
|
726
|
-
break;
|
|
727
|
-
case '/':
|
|
728
|
-
src[i] /= +value.substr(1);
|
|
729
|
-
break;
|
|
730
|
-
default:
|
|
731
|
-
src[i] = +value;
|
|
732
|
-
}
|
|
733
|
-
} else if (type(value) === 'number') {
|
|
734
|
-
src[i] = value;
|
|
735
|
-
} else {
|
|
736
|
-
throw new Error("unsupported value for Color.set");
|
|
737
|
-
}
|
|
738
|
-
var out = new Color$2(src, mode);
|
|
739
|
-
if (mutate) {
|
|
740
|
-
this._rgb = out._rgb;
|
|
741
|
-
return this;
|
|
742
|
-
}
|
|
743
|
-
return out;
|
|
744
|
-
}
|
|
745
|
-
throw new Error(("unknown channel " + channel + " in mode " + mode));
|
|
746
|
-
} else {
|
|
747
|
-
return src;
|
|
748
|
-
}
|
|
749
|
-
};
|
|
750
|
-
|
|
751
|
-
var Color$1 = Color_1;
|
|
752
|
-
|
|
753
|
-
var rgb = function (col1, col2, f) {
|
|
754
|
-
var xyz0 = col1._rgb;
|
|
755
|
-
var xyz1 = col2._rgb;
|
|
756
|
-
return new Color$1(
|
|
757
|
-
xyz0[0] + f * (xyz1[0]-xyz0[0]),
|
|
758
|
-
xyz0[1] + f * (xyz1[1]-xyz0[1]),
|
|
759
|
-
xyz0[2] + f * (xyz1[2]-xyz0[2]),
|
|
760
|
-
'rgb'
|
|
761
|
-
)
|
|
762
|
-
};
|
|
763
|
-
|
|
764
|
-
// register interpolator
|
|
765
|
-
interpolator$1.rgb = rgb;
|
|
766
|
-
|
|
767
|
-
var Color = Color_1;
|
|
768
|
-
|
|
769
|
-
var _hsx = function (col1, col2, f, m) {
|
|
770
|
-
var assign, assign$1;
|
|
771
|
-
|
|
772
|
-
var xyz0, xyz1;
|
|
773
|
-
if (m === 'hsl') {
|
|
774
|
-
xyz0 = col1.hsl();
|
|
775
|
-
xyz1 = col2.hsl();
|
|
776
|
-
} else if (m === 'hsv') {
|
|
777
|
-
xyz0 = col1.hsv();
|
|
778
|
-
xyz1 = col2.hsv();
|
|
779
|
-
} else if (m === 'hcg') {
|
|
780
|
-
xyz0 = col1.hcg();
|
|
781
|
-
xyz1 = col2.hcg();
|
|
782
|
-
} else if (m === 'hsi') {
|
|
783
|
-
xyz0 = col1.hsi();
|
|
784
|
-
xyz1 = col2.hsi();
|
|
785
|
-
} else if (m === 'lch' || m === 'hcl') {
|
|
786
|
-
m = 'hcl';
|
|
787
|
-
xyz0 = col1.hcl();
|
|
788
|
-
xyz1 = col2.hcl();
|
|
789
|
-
} else if (m === 'oklch') {
|
|
790
|
-
xyz0 = col1.oklch().reverse();
|
|
791
|
-
xyz1 = col2.oklch().reverse();
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
var hue0, hue1, sat0, sat1, lbv0, lbv1;
|
|
795
|
-
if (m.substr(0, 1) === 'h' || m === 'oklch') {
|
|
796
|
-
(assign = xyz0, hue0 = assign[0], sat0 = assign[1], lbv0 = assign[2]);
|
|
797
|
-
(assign$1 = xyz1, hue1 = assign$1[0], sat1 = assign$1[1], lbv1 = assign$1[2]);
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
var sat, hue, lbv, dh;
|
|
801
|
-
|
|
802
|
-
if (!isNaN(hue0) && !isNaN(hue1)) {
|
|
803
|
-
// both colors have hue
|
|
804
|
-
if (hue1 > hue0 && hue1 - hue0 > 180) {
|
|
805
|
-
dh = hue1 - (hue0 + 360);
|
|
806
|
-
} else if (hue1 < hue0 && hue0 - hue1 > 180) {
|
|
807
|
-
dh = hue1 + 360 - hue0;
|
|
808
|
-
} else {
|
|
809
|
-
dh = hue1 - hue0;
|
|
810
|
-
}
|
|
811
|
-
hue = hue0 + f * dh;
|
|
812
|
-
} else if (!isNaN(hue0)) {
|
|
813
|
-
hue = hue0;
|
|
814
|
-
if ((lbv1 == 1 || lbv1 == 0) && m != 'hsv') { sat = sat0; }
|
|
815
|
-
} else if (!isNaN(hue1)) {
|
|
816
|
-
hue = hue1;
|
|
817
|
-
if ((lbv0 == 1 || lbv0 == 0) && m != 'hsv') { sat = sat1; }
|
|
818
|
-
} else {
|
|
819
|
-
hue = Number.NaN;
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
if (sat === undefined) { sat = sat0 + f * (sat1 - sat0); }
|
|
823
|
-
lbv = lbv0 + f * (lbv1 - lbv0);
|
|
824
|
-
return m === 'oklch' ? new Color([lbv, sat, hue], m) : new Color([hue, sat, lbv], m);
|
|
825
|
-
};
|
|
826
|
-
|
|
827
|
-
var interpolate_hsx = _hsx;
|
|
828
|
-
|
|
829
|
-
var lch = function (col1, col2, f) {
|
|
830
|
-
return interpolate_hsx(col1, col2, f, 'lch');
|
|
831
|
-
};
|
|
832
|
-
|
|
833
|
-
// register interpolator
|
|
834
|
-
interpolator$1.lch = lch;
|
|
835
|
-
interpolator$1.hcl = lch;
|
|
836
|
-
|
|
837
|
-
var chroma = chroma_1;
|
|
838
|
-
|
|
839
|
-
// feel free to comment out anything to rollup
|
|
840
|
-
// a smaller chroma.js built
|
|
841
|
-
|
|
842
|
-
// io --> convert colors
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
// operators --> modify existing Colors
|
|
848
|
-
// required by .mix()
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
// interpolators
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
// generators -- > create new colors
|
|
859
|
-
chroma.mix = chroma.interpolate = mix$1;
|
|
860
|
-
|
|
861
|
-
var indexCustom = chroma;
|
|
862
|
-
|
|
863
|
-
return indexCustom;
|
|
864
|
-
|
|
865
|
-
}));
|