1 /*---------------------------------------------------------------------------------------------
2 * Copyright (c) Microsoft Corporation. All rights reserved.
3 * Licensed under the MIT License. See License.txt in the project root for license information.
4 *--------------------------------------------------------------------------------------------*/
6 if (typeof module === "object" && typeof module.exports === "object") {
7 var v = factory(require, exports);
8 if (v !== undefined) module.exports = v;
10 else if (typeof define === "function" && define.amd) {
11 define(["require", "exports"], factory);
13 })(function (require, exports) {
15 Object.defineProperty(exports, "__esModule", { value: true });
16 exports.colorFrom256RGB = exports.colorFromHex = exports.hexDigit = void 0;
22 function hexDigit(charCode) {
23 if (charCode < Digit0) {
26 if (charCode <= Digit9) {
27 return charCode - Digit0;
32 if (charCode >= a && charCode <= f) {
33 return charCode - a + 10;
37 exports.hexDigit = hexDigit;
38 function colorFromHex(text) {
39 if (text[0] !== '#') {
42 switch (text.length) {
45 red: (hexDigit(text.charCodeAt(1)) * 0x11) / 255.0,
46 green: (hexDigit(text.charCodeAt(2)) * 0x11) / 255.0,
47 blue: (hexDigit(text.charCodeAt(3)) * 0x11) / 255.0,
52 red: (hexDigit(text.charCodeAt(1)) * 0x11) / 255.0,
53 green: (hexDigit(text.charCodeAt(2)) * 0x11) / 255.0,
54 blue: (hexDigit(text.charCodeAt(3)) * 0x11) / 255.0,
55 alpha: (hexDigit(text.charCodeAt(4)) * 0x11) / 255.0,
59 red: (hexDigit(text.charCodeAt(1)) * 0x10 + hexDigit(text.charCodeAt(2))) / 255.0,
60 green: (hexDigit(text.charCodeAt(3)) * 0x10 + hexDigit(text.charCodeAt(4))) / 255.0,
61 blue: (hexDigit(text.charCodeAt(5)) * 0x10 + hexDigit(text.charCodeAt(6))) / 255.0,
66 red: (hexDigit(text.charCodeAt(1)) * 0x10 + hexDigit(text.charCodeAt(2))) / 255.0,
67 green: (hexDigit(text.charCodeAt(3)) * 0x10 + hexDigit(text.charCodeAt(4))) / 255.0,
68 blue: (hexDigit(text.charCodeAt(5)) * 0x10 + hexDigit(text.charCodeAt(6))) / 255.0,
69 alpha: (hexDigit(text.charCodeAt(7)) * 0x10 + hexDigit(text.charCodeAt(8))) / 255.0
74 exports.colorFromHex = colorFromHex;
75 function colorFrom256RGB(red, green, blue, alpha) {
76 if (alpha === void 0) { alpha = 1.0; }
84 exports.colorFrom256RGB = colorFrom256RGB;