UNPKG

style-js

Version:

Comprehensive color manipulation classes.

2,086 lines (1,950 loc) 196 kB
/** * Copyright 2012 Martin Gallagher * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ (function($, undefined) { 'use strict'; /** * Style.js major version * @private * @constant * @type {Number} */ var VERSION_MAJOR = 0; /** * Style.js minor version * @private * @constant * @type {Number} */ var VERSION_MINOR = 0; /** * Style.js patch version * @private * @constant * @type {Number} */ var VERSION_PATCH = 1; /** * Array of Style objects * @type {Array.<Style>} */ var Styles = []; /** * Default EM dimension in pixels * @type {Number} */ var emSize = 16; /** * Flag determines whether to output branding when creating CSS * @private * @type {Boolean} */ var branding = true; /** * Default unit type for measurements * @private * @type {String} */ var defaultUnit = 'px'; /** * Valid unit types for measurements * @private * @type {Object.<String, Boolean>} */ var validUnits = { 'px': true, 'em': true, 'ex': true, 'pt': true, 'pc': true, 'mm': true, 'cm': true, 'in': true, '%': true }; /** * Push string value to Styles array * @param {Array} styles */ String.prototype.toStyle = function(styles) { styles = styles === undefined ? Styles : styles; if (Type.isArray(styles)) { styles.push(this); } }; /** * Add values from an object to the current object * @returns {Object} */ Object.prototype.extend = function() { var len = arguments.length; if (len > 0) { for (var i = 0; i < len; ++i) { if (Type.isObject(arguments[i])) { for (var property in arguments[i]) { this[property] = arguments[i][property]; } } } } return this; }; /** * Set object value to null * @returns {null} */ Object.prototype.disable = function() { return null; }; /** * Attempt to transform object value to Style * @returns {Style} */ Object.prototype.toStyle = function() { return new Style(this); }; /** * Generic Color class for shared color functionality * @class */ function Color() { } $.Color = Color; /** * @static * @constant * @type {String} */ Color.NAMED = 'Named'; /** * @static * @constant * @type {String} */ Color.RED = 'red'; /** * @static * @constant * @type {String} */ Color.GREEN = 'green'; /** * @static * @constant * @type {String} */ Color.BLUE = 'blue'; /** * @static * @constant * @type {String} */ Color.RGB = 'RGB'; /** * @static * @constant * @type {String} */ Color.RGBA = 'RGBA'; /** * @static * @constant * @type {String} */ Color.RYB = 'RYB'; /** * @static * @constant * @type {String} */ Color.HEX = 'Hex'; /** * @static * @constant * @type {String} */ Color.HSL = 'HSL'; /** * @static * @constant * @type {String} */ Color.HSLA = 'HSLA'; /** * @static * @constant * @type {String} */ Color.HSV = 'HSV'; /** * @static * @constant * @type {String} */ Color.XYZ = 'XYZ'; /** * @static * @constant * @type {String} */ Color.XYY = 'xyY'; /** * @static * @constant * @type {String} */ Color.CIELAB = 'CIELab'; /** * @static * @constant * @type {String} */ Color.CIELUV = 'CIELuv'; /** * @static * @constant * @type {String} */ Color.CIELCH = 'CIELCH'; /** * @static * @constant * @type {String} */ Color.HUNTERLAB = 'HunterLab'; /** * @static * @constant * @type {String} */ Color.CMYK = 'CMYK'; /** * @static * @constant * @type {String} */ Color.CMY = 'CMY'; /** * @static * @constant * @type {String} */ Color.YIQ = 'YIQ'; /** * @static * @constant * @type {String} */ Color.YUV = 'YUV'; /** * @static * @constant * @type {String} */ Color.YDBDR = 'YDbDr'; /** * @static * @constant * @type {String} */ Color.YCBCR = 'YCbCr'; /** * @static * @constant * @type {String} */ Color.YPBPR = 'YPbPr'; /** * @static * @constant * @type {Object.<String, Boolean>} */ Color.types = {}; // Populate Color.types object for (var i in Color) { if (Color.hasOwnProperty(i) && Type.isString(Color[i]) && Color[i] !== 'Named') { Color.types[Color[i]] = true; } } /** * @static * @constant * @type {Object} */ Color.regex = { /** * @static * @constant * @type {Object} */ hex: /^\s*#[a-f0-9]{3,6}\s*$/i, /** * @static * @constant * @type {Object} */ RGB: /^\s*rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*$/i, /** * @static * @constant * @type {Object} */ RGBA: /^\s*rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\,\s*(\.\d+|\d+(\.\d+)?)\s*\)\s*$/i, /** * @static * @constant * @type {Object} */ HSL: /^\s*hsl\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)\s*$/i, /** * @static * @constant * @type {Object} */ HSLA: /^\s*hsla\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\,\s*(\.\d+|\d+(\.\d+)?)\s*\)\s*$/i, /** * @static * @constant * @type {Object} */ all: /(#[a-f0-9]{3,6}|rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)|rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\,\s*(\.\d+|\d+(\.\d+)?)\s*\)|hsl\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)|hsla\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\,\s*(\.\d+|\d+(\.\d+)?)\s*\))/gi }; /** * Color array comparators * @static * @constant * @type {Object.<String, Function>} */ Color.Comparators = {}; /** * Sort color array by brightness * @static * @param {Object|String} a * @param {Object|String} b * @returns {Number} */ Color.Comparators.sortByBrightness = function(a, b) { a = new RGB(a); b = new RGB(b); var validB = b && b.isSet(); if (a && a.isSet()) { if (validB) { a = brightness(a); b = brightness(b); return a === b ? 0 : (a < b ? 1 : -1); } return -1; } return validB ? 1 : 0; }; /** * Sort color array by hue * @static * @param {Object|String} a * @param {Object|String} b * @returns {Number} */ Color.Comparators.sortByHue = function(a, b) { a = new HSL(a); b = new HSL(b); var validB = b && b.isSet(); if (a && a.isSet()) { if (validB) { return a.hue === b.hue ? 0 : (a.hue < b.hue ? 1 : -1); } return -1; } return validB ? 1 : 0; }; /** * Sort color array by absolute red value * @static * @param {Object|String} a * @param {Object|String} b * @returns {Number} */ Color.Comparators.sortByRed = function(a, b) { a = new RGB(a); b = new RGB(b); var validB = b && b.isSet(); if (a && a.isSet()) { if (validB) { if (a.red === b.red) { var totalA = a.green + a.blue; var totalB = b.green + b.blue; if (totalA === totalB) { return 0; } else if (totalA < totalB) { return -1; } else { return 1; } } else { return a.red < b.red ? 1 : -1; } } return -1; } return validB ? 1 : 0; }; /** * Sort color array by absolute green value * @static * @param {Object|String} a * @param {Object|String} b * @returns {Number} */ Color.Comparators.sortByGreen = function(a, b) { a = new RGB(a); b = new RGB(b); var validB = b && b.isSet(); if (a && a.isSet()) { if (validB) { if (a.green === b.green) { var totalA = a.red + a.blue; var totalB = b.red + b.blue; if (totalA === totalB) { return 0; } else if (totalA < totalB) { return -1; } else { return 1; } } else { return a.green < b.green ? 1 : -1; } } return -1; } return validB ? 1 : 0; }; /** * Sort color array by absolute blue value * @static * @param {Object|String} a * @param {Object|String} b * @returns {Number} */ Color.Comparators.sortByBlue = function(a, b) { a = new RGB(a); b = new RGB(b); var validB = b && b.isSet(); if (a && a.isSet()) { if (validB) { if (a.blue === b.blue) { var totalA = a.red + a.green; var totalB = b.red + b.green; if (totalA === totalB) { return 0; } else if (totalA < totalB) { return -1; } else { return 1; } } else { return a.blue < b.blue ? 1 : -1; } } return -1; } return validB ? 1 : 0; }; /** * Sort color array by relative red value * @static * @param {Object|String} a * @param {Object|String} b * @returns {Number} */ Color.Comparators.sortByRedRelative = function(a, b) { a = new RGB(a); b = new RGB(b); var validB = b && b.isSet(); if (a && a.isSet()) { if (validB) { var totalA = a.red - (a.green + a.blue); var totalB = b.red - (b.green + b.blue); if (totalA === totalB) { if (a.red === b.red) { return 0; } else { return a.red < b.red ? 1 : -1; } } else { return totalA < totalB ? 1 : -1; } } return -1; } return validB ? 1 : 0; }; /** * Sort color array by relative green value * @static * @param {Object|String} a * @param {Object|String} b * @returns {Number} */ Color.Comparators.sortByGreenRelative = function(a, b) { a = new RGB(a); b = new RGB(b); var validB = b && b.isSet(); if (a && a.isSet()) { if (validB) { var totalA = a.green - (a.red + a.blue); var totalB = b.green - (b.red + b.blue); if (totalA === totalB) { if (a.green === b.green) { return 0; } else { return a.green < b.green ? 1 : -1; } } else { return totalA < totalB ? 1 : -1; } } return -1; } return validB ? 1 : 0; }; /** * Sort color array by relative blue value * @static * @param {Object|String} a * @param {Object|String} b * @returns {Number} */ Color.Comparators.sortByBlueRelative = function(a, b) { a = new RGB(a); b = new RGB(b); var validB = b && b.isSet(); if (a && a.isSet()) { if (validB) { var totalA = a.blue - (a.red + a.green); var totalB = b.blue - (b.red + b.green); if (totalA === totalB) { if (a.blue === b.blue) { return 0; } else { return a.blue < b.blue ? 1 : -1; } } else { return totalA < totalB ? 1 : -1; } } return -1; } return validB ? 1 : 0; }; /** * Common color depths * @static * @constant * @type {Object.<Number, Array>} */ Color.depth = { 3: [1, 1, 1], 6: [2, 2, 2], 9: [3, 3, 3], 12: [4, 4, 4], 15: [5, 5, 5], 16: [5, 6, 5], 18: [6, 6, 6], 21: [7, 7, 7], 24: [8, 8, 8] }; /** * @static * @constant * @type {Object.<String, String>} */ Color.webSafe = { 'ffffff': 'white', 'c0c0c0': 'silver', '808080': 'gray', '000000': 'black', 'ff0000': 'red', '800000': 'maroon', 'ffff00': 'yellow', '808000': 'olive', '00ff00': 'lime', '008000': 'green', '00ffff': 'aqua', '008080': 'teal', '0000ff': 'blue', '000080': 'navy', 'ff00ff': 'fuchsia', '800080': 'purple' }; /** * @static * @constant * @type {Object.<String, String|Array>} */ Color.list = { 'f0f8ff': 'aliceblue', 'faebd7': 'antiquewhite', '7fffd4': 'aquamarine', 'f0ffff': 'azure', 'f5f5dc': 'beige', 'ffe4c4': 'bisque', 'ffebcd': 'blanchedalmond', '8a2be2': 'blueviolet', 'a52a2a': 'brown', 'deb887': 'burlywood', '5f9ea0': 'cadetblue', '7fff00': 'chartreuse', 'd2691e': 'chocolate', 'ff7f50': 'coral', '6495ed': 'cornflowerblue', 'fff8dc': 'cornsilk', 'dc143c': 'crimson', '00008b': 'darkblue', '008b8b': 'darkcyan', 'b8860b': 'darkgoldenrod', 'a9a9a9': ['darkgray', 'darkgrey'], '006400': 'darkgreen', 'bdb76b': 'darkkhaki', '8b008b': 'darkmagenta', '556b2f': 'darkolivegreen', 'ff8c00': 'darkorange', '9932cc': 'darkorchid', '8b0000': 'darkred', 'e9967a': 'darksalmon', '8fbc8f': 'darkseagreen', '483d8b': 'darkslateblue', '2f4f4f': ['darkslategray', 'darkslategrey'], '00ced1': 'darkturquoise', '9400d3': 'darkviolet', 'ff1493': 'deeppink', '00bfff': 'deepskyblue', '696969': ['dimgray', 'dimgrey'], '1e90ff': 'dodgerblue', 'b22222': 'firebrick', 'fffaf0': 'floralwhite', '228b22': 'forestgreen', 'dcdcdc': 'gainsboro', 'f8f8ff': 'ghostwhite', 'ffd700': 'gold', 'daa520': 'goldenrod', 'adff2f': 'greenyellow', 'f0fff0': 'honeydew', 'ff69b4': 'hotpink', 'cd5c5c': 'indianred ', '4b0082': 'indigo ', 'fffff0': 'ivory', 'f0e68c': 'khaki', 'e6e6fa': 'lavender', 'fff0f5': 'lavenderblush', '7cfc00': 'lawngreen', 'fffacd': 'lemonchiffon', 'add8e6': 'lightblue', 'f08080': 'lightcoral', 'e0ffff': 'lightcyan', 'fafad2': 'lightgoldenrodyellow', 'd3d3d3': ['lightgray', 'lightgrey'], '90ee90': 'lightgreen', 'ffb6c1': 'lightpink', 'ffa07a': 'lightsalmon', '20b2aa': 'lightseagreen', '87cefa': 'lightskyblue', '778899': ['lightslategray', 'lightslategrey'], 'b0c4de': 'lightsteelblue', 'ffffe0': 'lightyellow', '32cd32': 'limegreen', 'faf0e6': 'linen', '66cdaa': 'mediumaquamarine', '0000cd': 'mediumblue', 'ba55d3': 'mediumorchid', '9370d8': 'mediumpurple', '3cb371': 'mediumseagreen', '7b68ee': 'mediumslateblue', '00fa9a': 'mediumspringgreen', '48d1cc': 'mediumturquoise', 'c71585': 'mediumvioletred', '191970': 'midnightblue', 'f5fffa': 'mintcream', 'ffe4e1': 'mistyrose', 'ffe4b5': 'moccasin', 'ffdead': 'navajowhite', 'fdf5e6': 'oldlace', '6b8e23': 'olivedrab', 'ffa500': 'orange', 'ff4500': 'orangered', 'da70d6': 'orchid', 'eee8aa': 'palegoldenrod', '98fb98': 'palegreen', 'afeeee': 'paleturquoise', 'd87093': 'palevioletred', 'ffefd5': 'papayawhip', 'ffdab9': 'peachpuff', 'cd853f': 'peru', 'ffc0cb': 'pink', 'dda0dd': 'plum', 'b0e0e6': 'powderblue', 'bc8f8f': 'rosybrown', '4169e1': 'royalblue', '8b4513': 'saddlebrown', 'fa8072': 'salmon', 'f4a460': 'sandybrown', '2e8b57': 'seagreen', 'fff5ee': 'seashell', 'a0522d': 'sienna', '87ceeb': 'skyblue', '6a5acd': 'slateblue', '708090': ['slategray', 'slategrey'], 'fffafa': 'snow', '00ff7f': 'springgreen', '4682b4': 'steelblue', 'd2b48c': 'tan', 'd8bfd8': 'thistle', 'ff6347': 'tomato', '40e0d0': 'turquoise', 'ee82ee': 'violet', 'f5deb3': 'wheat', 'f5f5f5': 'whitesmoke', '9acd32': 'yellowgreen' }.extend(Color.webSafe); /** * @static * @constant * @type {Object.<String, String|Array>} */ Color.listExtended = { 'c9ffe5': 'Aero blue', '5d8aa8': ['Air Force blue (RAF)', 'Rackley'], '00308f': 'Air Force blue (USAF)', '72a0c1': 'Air superiority blue', 'a32638': 'Alabama Crimson', 'f0f8ff': 'Alice blue', 'e32636': ['Alizarin crimson', 'Rose madder'], 'c46210': 'Alloy orange', 'efdecd': 'Almond', 'e52b50': 'Amaranth', '3b7a57': 'Amazon', 'ffbf00': ['Amber', 'Fluorescent orange'], 'ff7e00': 'SAE/ECE Amber', 'ff033e': 'American rose', '9966cc': 'Amethyst', 'a4c639': 'Android Green', 'f2f3f4': 'Anti-flash white', 'cd9575': 'Antique brass', '665d1e': 'Antique bronze', '915c83': 'Antique fuchsia', '841b2d': 'Antique ruby', 'faebd7': ['Antique white', 'Moccasin'], '008000': ['Ao', 'Green', 'Office green'], '8db600': 'Apple green', 'fbceb1': 'Apricot', '00ffff': ['Aqua', 'Cyan', 'Electric cyan'], '7fffd4': 'Aquamarine', '4b5320': 'Army green', '3b444b': 'Arsenic', 'e9d66b': ['Arylide yellow', 'Hansa yellow'], 'b2beb5': 'Ash grey', '87a96b': 'Asparagus', 'ff9966': ['Atomic tangerine', 'Pink-orange'], 'a52a2a': ['Auburn', 'Brown', 'Red-brown'], 'fdee00': 'Aureolin', '6e7f80': 'AuroMetalSaurus', '568203': 'Avocado', '007fff': 'Azure', 'f0ffff': 'Azure mist/web', '89cff0': 'Baby blue', 'a1caf1': 'Baby blue eyes', 'f4c2c2': ['Baby pink', 'Tea rose (rose)'], 'fefefa': 'Baby powder', 'ff91af': ['Baker-Miller pink', 'Schauss pink'], '21abcd': 'Ball Blue', 'fae7b5': 'Banana Mania', 'ffe135': 'Banana yellow', '7c0a02': 'Barn red', '848482': ['Battleship grey', 'Old silver'], '98777b': 'Bazaar', 'bcd4e6': ['Beau blue', 'Pale aqua'], '9f8170': 'Beaver', 'f5f5dc': 'Beige', '2e5894': 'B\'dazzled Blue', '9c2542': 'Big dip o’ruby', 'ffe4c4': 'Bisque', '3d2b1f': 'Bistre', '967117': ['Bistre brown', 'Drab', 'Mode beige', 'Sand dune', 'Sandy taupe'], 'cae00d': 'Bitter lemon', 'bfff00': ['Bitter lime', 'Lime'], 'fe6f5e': 'Bittersweet', 'bf4f51': 'Bittersweet shimmer', '000000': 'Black', '3d0c02': 'Black bean', '253529': 'Black leather jacket', '3b3c36': 'Black olive', 'ffebcd': 'Blanched Almond', 'a57164': 'Blast-off bronze', '318ce7': 'Bleu de France', 'ace5ee': 'Blizzard Blue', 'faf0be': 'Blond', '0000ff': 'Blue', '1f75fe': 'Blue (Crayola)', '0093af': 'Blue (Munsell)', '0087bd': 'Blue (NCS)', '333399': 'Blue (pigment)', '0247fe': 'Blue (RYB)', 'a2a2d0': 'Blue Bell', '6699cc': 'Blue-gray', '0d98ba': 'Blue-green', '126180': 'Blue sapphire', '8a2be2': 'Blue-violet', '4f86f7': 'Blueberry', '1c1cf0': 'Bluebonnet', 'de5d83': 'Blush', '79443b': ['Bole', 'Medium Tuscan red'], '0095b6': 'Bondi blue', 'e3dac9': 'Bone', 'cc0000': 'Boston University Red', '006a4e': 'Bottle green', '873260': 'Boysenberry', '0070ff': 'Brandeis blue', 'b5a642': 'Brass', 'cb4154': 'Brick red', '1dacd6': 'Bright cerulean', '66ff00': 'Bright green', 'bf94e4': 'Bright lavender', 'c32148': ['Bright maroon', 'Maroon (Crayola)'], 'ff007f': ['Bright pink', 'Rose'], '08e8de': 'Bright turquoise', 'd19fe8': 'Bright ube', 'f4bbff': ['Brilliant lavender', 'Electric lavender'], 'ff55a3': ['Brilliant rose', 'Magenta (Crayola)'], 'fb607f': 'Brink pink', '004225': 'British racing green', 'cd7f32': 'Bronze', '737000': 'Bronze Yellow', '964b00': 'Brown (traditional)', '6b4423': ['Brown-nose', 'Flattery'], '1b4d3e': ['Brunswick green', 'English green'], 'ffc1cc': 'Bubble gum', 'e7feff': 'Bubbles', 'f0dc82': 'Buff', '480607': 'Bulgarian rose', '800020': 'Burgundy', 'deb887': 'Burlywood', 'cc5500': 'Burnt orange', 'e97451': ['Burnt sienna', 'Light red ochre'], '8a3324': 'Burnt umber', 'bd33a4': 'Byzantine', '702963': 'Byzantium', '536872': 'Cadet', '5f9ea0': 'Cadet blue', '91a3b0': 'Cadet grey', '006b3c': 'Cadmium green', 'ed872d': 'Cadmium orange', 'e30022': 'Cadmium red', 'fff600': 'Cadmium yellow', 'a67b5b': ['Café au lait', 'French beige', 'Tuscan tan'], '4b3621': 'Café noir', '1e4d2b': 'Cal Poly green', 'a3c1ad': 'Cambridge Blue', 'c19a6b': ['Camel', 'Desert', 'Fallow', 'Lion', 'Wood brown'], 'efbbcc': 'Cameo pink', '78866b': 'Camouflage green', 'ffef00': ['Canary yellow', 'Yellow (process)'], 'ff0800': 'Candy apple red', 'e4717a': ['Candy pink', 'Tango pink'], '00bfff': ['Capri', 'Deep sky blue'], '592720': 'Caput mortuum', 'c41e3a': 'Cardinal', '00cc99': 'Caribbean green', '960018': 'Carmine', 'd70040': ['Carmine (M&amp;P)', 'Rich carmine'], 'eb4c42': 'Carmine pink', 'ff0038': 'Carmine red', 'ffa6c9': 'Carnation pink', 'b31b1b': ['Carnelian', 'Cornell Red'], '99badd': 'Carolina blue', 'ed9121': 'Carrot orange', '00563f': ['Castleton green', 'Sacramento State green'], '062a78': 'Catalina blue', 'c95a49': 'Cedar Chest', '92a1cf': 'Ceil', 'ace1af': 'Celadon', '007ba7': ['Celadon Blue', 'Cerulean'], '2f847c': 'Celadon Green', 'b2ffff': ['Celeste', 'Italian sky blue'], '4997d0': 'Celestial blue', 'de3163': ['Cerise', 'Cherry'], 'ec3b83': 'Cerise pink', '2a52be': 'Cerulean blue', '6d9bc3': 'Cerulean frost', '007aa5': 'CG Blue', 'e03c31': 'CG Red', 'a0785a': 'Chamoisee', 'f7e7ce': 'Champagne', '36454f': 'Charcoal', '232b2b': 'Charleston green', 'e68fac': ['Charm pink', 'Light Thulian pink'], 'dfff00': 'Chartreuse (traditional)', '7fff00': 'Chartreuse', 'ffb7c5': 'Cherry blossom pink', '954535': 'Chestnut', 'de6fa1': ['China pink', 'Thulian pink'], 'a8516e': 'China rose', 'aa381e': 'Chinese red', '7b3f00': 'Chocolate (traditional)', 'd2691e': ['Chocolate', 'Cinnamon', 'Cocoa brown'], 'ffa700': 'Chrome yellow', '98817b': 'Cinereous', 'e34234': ['Cinnabar', 'Vermilion (cinnabar)'], 'e4d00a': 'Citrine', '9fa91f': 'Citron', '7f1734': 'Claret', 'fbcce7': 'Classic rose', '0047ab': 'Cobalt', '965a3e': 'Coconut', '6f4e37': ['Coffee', 'Tuscan brown'], '9bddff': 'Columbia blue', 'f88379': ['Congo pink', 'Coral pink', 'Tea rose (orange)'], '002e63': 'Cool black', '8c92ac': ['Cool grey', 'Gray-blue'], 'b87333': 'Copper', 'da8a67': ['Copper (Crayola)', 'Pale copper'], 'ad6f69': 'Copper penny', 'cb6d51': 'Copper red', '996666': 'Copper rose', 'ff3800': 'Coquelicot', 'ff7f50': 'Coral', 'ff4040': 'Coral red', '893f45': 'Cordovan', 'fbec5d': ['Corn', 'Maize'], '6495ed': 'Cornflower blue', 'fff8dc': 'Cornsilk', 'fff8e7': 'Cosmic latte', 'ffbcd9': 'Cotton candy', 'fffdd0': 'Cream', 'dc143c': 'Crimson', 'be0032': 'Crimson glory', '00b7eb': 'Cyan (process)', '58427c': 'Cyber Grape', 'ffff31': 'Daffodil', 'f0e130': 'Dandelion', '00008b': 'Dark blue', '666699': 'Dark blue-gray', '654321': ['Dark brown', 'Otter brown'], '5d3954': 'Dark byzantium', 'a40000': 'Dark candy apple red', '08457e': 'Dark cerulean', '986960': 'Dark chestnut', 'cd5b45': 'Dark coral', '008b8b': 'Dark cyan', '536878': ['Dark electric blue', 'Payne\'s grey'], 'b8860b': 'Dark goldenrod', 'a9a9a9': 'Dark gray', '013220': 'Dark green', '00416a': ['Dark imperial blue', 'Indigo (dye)'], '1a2421': 'Dark jungle green', 'bdb76b': 'Dark khaki', '483c32': ['Dark lava', 'Dark taupe', 'Taupe'], '734f96': 'Dark lavender', '8b008b': 'Dark magenta', '003366': 'Dark midnight blue', '556b2f': 'Dark olive green', 'ff8c00': 'Dark orange', '9932cc': 'Dark orchid', '779ecb': 'Dark pastel blue', '03c03c': 'Dark pastel green', '966fd6': 'Dark pastel purple', 'c23b22': 'Dark pastel red', 'e75480': 'Dark pink', '003399': ['Dark powder blue', 'Smalt (Dark powder blue)'], '872657': 'Dark raspberry', '8b0000': 'Dark red', 'e9967a': 'Dark salmon', '560319': 'Dark scarlet', '8fbc8f': 'Dark sea green', '3c1414': 'Dark sienna', '8cbed6': 'Dark sky blue', '483d8b': 'Dark slate blue', '2f4f4f': 'Dark slate gray', '177245': 'Dark spring green', '918151': 'Dark tan', 'ffa812': 'Dark tangerine', 'cc4e5c': 'Dark terra cotta', '00ced1': 'Dark turquoise', 'd1bea8': 'Dark vanilla', '9400d3': 'Dark violet', '9b870c': 'Dark yellow', '00703c': 'Dartmouth green', '555555': 'Davy\'s grey', 'd70a53': 'Debian red', 'a9203e': 'Deep carmine', 'ef3038': 'Deep carmine pink', 'e9692c': 'Deep carrot orange', 'da3287': 'Deep cerise', 'fad6a5': ['Deep champagne', 'Sunset', 'Tuscan'], 'b94e48': 'Deep chestnut', '704241': 'Deep coffee', 'c154c1': ['Deep fuchsia', 'Fuchsia (Crayola)'], '004b49': 'Deep jungle green', 'f5c71a': 'Deep lemon', '9955bb': 'Deep lilac', 'cc00cc': 'Deep magenta', 'd473d4': ['Deep mauve', 'French mauve'], 'ffcba4': ['Deep peach', 'Peach (Crayola)'], 'ff1493': ['Deep pink', 'Fluorescent pink'], '843f5b': 'Deep ruby', 'ff9933': 'Deep saffron', '4a646c': 'Deep Space Sparkle', '7e5e60': 'Deep Taupe', '66424d': 'Deep Tuscan red', 'ba8759': 'Deer', '1560bd': 'Denim', 'edc9af': 'Desert sand', '7d1242': 'Diamond', '696969': 'Dim gray', '9b7653': 'Dirt', '1e90ff': 'Dodger blue', 'd71868': 'Dogwood rose', '85bb65': 'Dollar bill', '00009c': 'Duke blue', 'e5ccc9': 'Dust storm', 'e1a95f': 'Earth yellow', '555d50': 'Ebony', 'c2b280': ['Ecru', 'Sand'], '614051': 'Eggplant', 'f0ead6': 'Eggshell', '1034a6': 'Egyptian blue', '7df9ff': 'Electric blue', 'ff003f': 'Electric crimson', '00ff00': ['Electric green', 'Green (X11 green)', 'Lime (X11 green)'], '6f00ff': ['Electric indigo', 'Indigo'], 'ccff00': ['Electric lime', 'Fluorescent yellow'], 'bf00ff': 'Electric purple', '3f00ff': 'Electric ultramarine', '8f00ff': ['Electric violet', 'Violet'], 'ffff33': 'Electric yellow', '50c878': ['Emerald', 'Paris Green'], 'b48395': 'English lavender', 'ab4b52': 'English red', '96c8a2': 'Eton blue', '44d7a8': 'Eucalyptus', '801818': 'Falu red', 'b53389': 'Fandango', 'de5285': 'Fandango pink', 'f400a1': ['Fashion fuchsia', 'Hollywood cerise'], 'e5aa70': 'Fawn', '4d5d53': 'Feldgrau', 'fdd5b1': ['Feldspar', 'Light apricot'], '4f7942': 'Fern green', 'ff2800': 'Ferrari Red', '6c541e': 'Field drab', 'b22222': 'Firebrick', 'ce2029': 'Fire engine red', 'e25822': 'Flame', 'fc8eac': 'Flamingo pink', 'f7e98e': 'Flavescent', 'eedc82': 'Flax', 'fffaf0': 'Floral white', 'ff004f': 'Folly', '014421': ['Forest green (traditional)', 'UP Forest green'], '228b22': 'Forest green', '856d4d': 'French bistre', '0072bb': 'French blue', '86608e': ['French lilac', 'Pomp and Power'], '9efd38': 'French lime', 'c72c48': 'French raspberry', 'f64a8a': 'French rose', '77b5fe': 'French sky blue', 'ac1e44': 'French wine', 'a6e7ff': 'Fresh Air', 'ff00ff': ['Fuchsia', 'Magenta'], 'ff77ff': 'Fuchsia pink', 'c74375': 'Fuchsia rose', 'e48400': 'Fulvous', 'cc6666': 'Fuzzy Wuzzy', 'dcdcdc': 'Gainsboro', 'e49b0f': 'Gamboge', 'f8f8ff': 'Ghost white', 'fe5a1d': 'Giants orange', 'b06500': 'Ginger', '6082b6': 'Glaucous', 'e6e8fa': 'Glitter', '00ab66': 'GO green', 'd4af37': 'Gold (metallic)', 'ffd700': 'Gold (Golden)', '85754e': 'Gold Fusion', '996515': 'Golden brown', 'fcc200': 'Golden poppy', 'ffdf00': 'Golden yellow', 'daa520': 'Goldenrod', 'a8e4a0': 'Granny Smith Apple', '6f2da8': 'Grape', '808080': ['Gray', 'Gray', 'Trolley Grey'], 'bebebe': 'Gray (X11 gray)', '465945': 'Gray-asparagus', '1cac78': 'Green (Crayola)', '00a877': 'Green (Munsell)', '009f6b': 'Green (NCS)', '00a550': 'Green (pigment)', '66b032': 'Green (RYB)', 'adff2f': 'Green-yellow', 'a99a86': 'Grullo', '00ff7f': ['Guppie green', 'Spring green'], '663854': 'Halayà úbe', '446ccf': 'Han blue', '5218fa': 'Han purple', '3fff00': 'Harlequin', 'c90016': 'Harvard crimson', 'da9100': 'Harvest Gold', '808000': ['Heart Gold', 'Olive'], 'df73ff': 'Heliotrope', 'f0fff0': 'Honeydew', '006db0': 'Honolulu blue', '49796b': 'Hooker\'s green', 'ff1dce': 'Hot magenta', 'ff69b4': 'Hot pink', '355e3b': 'Hunter green', '71a6d2': 'Iceberg', 'fcf75e': 'Icterine', '319177': 'Illuminating Emerald', '602f6b': 'Imperial', '002395': 'Imperial blue', 'b2ec5d': 'Inchworm', '138808': 'India green', 'cd5c5c': 'Indian red', 'e3a857': 'Indian yellow', '4b0082': 'Indigo', '002fa7': 'International Klein Blue', 'ff4f00': 'International orange (aerospace)', 'ba160c': 'International orange (engineering)', 'c0362c': 'International orange (Golden Gate Bridge)', '5a4fcf': 'Iris', 'b3446c': ['Irresistible', 'Raspberry rose'], 'f4f0ec': 'Isabelline', '009000': 'Islamic green', 'fffff0': 'Ivory', '00a86b': 'Jade', 'f8de7e': ['Jasmine', 'Mellow yellow'], 'd73b3e': 'Jasper', 'a50b5e': 'Jazzberry jam', 'da614e': 'Jelly Bean', '343434': 'Jet', 'f4ca16': 'Jonquil', 'bdda57': 'June bud', '29ab87': 'Jungle green', '4cbb17': 'Kelly green', '7c1c05': 'Kenyan copper', 'c3b091': 'Khaki', 'f0e68c': ['Khaki (X11) (Light khaki)', 'Light khaki'], '882d17': ['Kobe', 'Sienna'], 'e79fc4': 'Kobi', 'e8000d': 'KU Crimson', '087830': 'La Salle Green', 'd6cadd': 'Languid lavender', '26619c': 'Lapis lazuli', 'ffff66': ['Laser Lemon', 'Unmellow Yellow'], 'a9ba9d': 'Laurel green', 'cf1020': 'Lava', 'b57edc': 'Lavender (floral)', 'e6e6fa': ['Lavender', 'Lavender mist'], 'ccccff': ['Lavender blue', 'Periwinkle'], 'fff0f5': 'Lavender blush', 'c4c3d0': 'Lavender gray', '9457eb': ['Lavender indigo', 'Navy purple'], 'ee82ee': ['Lavender magenta', 'Violet'], 'fbaed2': 'Lavender pink', '967bb6': 'Lavender purple', 'fba0e3': 'Lavender rose', '7cfc00': 'Lawn green', 'fff700': 'Lemon', 'fffacd': 'Lemon chiffon', 'cca01d': 'Lemon curry', 'e3ff00': 'Lemon lime', 'f6eabe': 'Lemon meringue', 'fff44f': 'Lemon yellow', '1a1110': 'Licorice', 'add8e6': 'Light blue', 'b5651d': 'Light brown', 'e66771': 'Light carmine pink', 'f08080': 'Light coral', '93ccea': 'Light cornflower blue', 'f56991': 'Light crimson', 'e0ffff': 'Light cyan', 'f984ef': 'Light fuchsia pink', 'fafad2': 'Light goldenrod yellow', 'd3d3d3': 'Light gray', '90ee90': 'Light green', 'd39bcb': 'Light medium orchid', 'e6a8d7': 'Light orchid', 'b19cd9': 'Light pastel purple', 'ffb6c1': 'Light pink', 'ffa07a': 'Light salmon', 'ff9999': 'Light salmon pink', '20b2aa': 'Light sea green', '87cefa': 'Light sky blue', '778899': 'Light slate gray', 'b0c4de': 'Light steel blue', 'b38b6d': 'Light taupe', 'ffffe0': 'Light yellow', 'c8a2c8': 'Lilac', '32cd32': 'Lime green', '9dc209': 'Limerick', '195905': 'Lincoln green', 'faf0e6': 'Linen', '6ca0dc': 'Little boy blue', '534b4f': 'Liver', 'ffe4cd': 'Lumber', 'e62020': 'Lust', 'ca1f7b': 'Magenta (dye)', 'd0417e': 'Magenta (Pantone)', 'ff0090': 'Magenta (process)', 'aaf0d1': 'Magic mint', 'f8f4ff': 'Magnolia', 'c04000': 'Mahogany', '6050dc': 'Majorelle Blue', '0bda51': 'Malachite', '979aaa': 'Manatee', 'ff8243': 'Mango Tango', '74c365': 'Mantis', '880085': 'Mardi Gras', '800000': 'Maroon', 'b03060': ['Maroon (X11)', 'Rich maroon'], 'e0b0ff': 'Mauve', '915f6d': ['Mauve taupe', 'Raspberry glace'], 'ef98aa': 'Mauvelous', '73c2fb': 'Maya blue', 'e5b73b': 'Meat brown', '66ddaa': 'Medium aquamarine', '0000cd': 'Medium blue', 'e2062c': 'Medium candy apple red', 'af4035': ['Medium carmine', 'Pale carmine'], 'f3e5ab': ['Medium champagne', 'Vanilla'], '035096': 'Medium electric blue', '1c352d': 'Medium jungle green', 'dda0dd': ['Medium lavender magenta', 'Pale plum', 'Plum'], 'ba55d3': 'Medium orchid', '0067a5': ['Medium Persian blue', 'Sapphire blue'], '9370db': 'Medium purple', 'bb3385': 'Medium red-violet', 'aa4069': 'Medium ruby', '3cb371': 'Medium sea green', '80daeb': 'Medium sky blue', '7b68ee': 'Medium slate blue', 'c9dc87': 'Medium spring bud', '00fa9a': 'Medium spring green', '674c47': 'Medium taupe', '48d1cc': 'Medium turquoise', 'd9603b': ['Medium vermilion', 'Vermilion (Plochere)'], 'c71585': ['Medium violet-red', 'Red-violet'], 'f8b878': 'Mellow apricot', 'fdbcb4': 'Melon', '0a7e8c': 'Metallic Seaweed', '9c7c38': 'Metallic Sunburst', 'e4007c': 'Mexican pink', '191970': 'Midnight blue', '004953': 'Midnight green (eagle green)', 'e3f988': 'Midori', 'ffc40c': 'Mikado yellow', '3eb489': 'Mint', 'f5fffa': 'Mint cream', '98ff98': 'Mint green', 'ffe4e1': 'Misty rose', '73a9c2': 'Moonstone blue', 'ae0c00': 'Mordant red 19', 'addfad': 'Moss green', '30ba8f': 'Mountain Meadow', '997a8d': 'Mountbatten pink', '18453b': 'MSU Green', 'c54b8c': 'Mulberry', 'ffdb58': 'Mustard', '21421e': 'Myrtle', 'f6adc6': 'Nadeshiko pink', '2a8000': 'Napier green', 'fada5e': ['Naples yellow', 'Royal yellow', 'Stil de grain yellow'], 'ffdead': 'Navajo white', '000080': 'Navy blue', 'ffa343': 'Neon Carrot', 'fe4164': 'Neon fuchsia', '39ff14': 'Neon green', '214fc6': 'New Car', 'd7837f': 'New York pink', 'a4dded': 'Non-photo blue', '059033': 'North Texas Green', 'e9ffdb': 'Nyanza', '0077be': 'Ocean Boat Blue', 'cc7722': 'Ochre', '43302e': 'Old burgundy', 'cfb53b': 'Old gold', 'fdf5e6': 'Old lace', '796878': 'Old lavender', '673147': ['Old mauve', 'Wine dregs'], 'c08081': 'Old rose', '6b8e23': 'Olive Drab #3', '3c341f': 'Olive Drab #7', '9ab973': 'Olivine', '353839': 'Onyx', 'b784a7': 'Opera mauve', 'ff7f00': 'Orange', 'fb9902': 'Orange (RYB)', 'ffa500': 'Orange (web color)', 'ff9f00': 'Orange peel', 'ff4500': 'Orange-red', 'da70d6': 'Orchid', 'f28dcd': 'Orchid pink', 'fb4f14': 'Orioles orange', '414a4c': 'Outer Space', 'ff6e4a': 'Outrageous Orange', '002147': 'Oxford Blue', '990000': ['OU Crimson Red', 'Stizza', 'USC Cardinal'], '006600': 'Pakistan green', '273be2': 'Palatinate blue', '682860': 'Palatinate purple', 'afeeee': ['Pale blue', 'Pale turquoise'], '987654': 'Pale brown', '9bc4e2': 'Pale cerulean', 'ddadaf': 'Pale chestnut', 'abcdef': 'Pale cornflower blue', 'e6be8a': 'Pale gold', 'eee8aa': 'Pale goldenrod', '98fb98': 'Pale green', 'dcd0ff': 'Pale lavender', 'f984e5': 'Pale magenta', 'fadadd': 'Pale pink', 'db7093': ['Pale red-violet', 'Pale violet-red'], '96ded1': 'Pale robin egg blue', 'c9c0bb': 'Pale silver', 'ecebbd': 'Pale spring bud', 'bc987e': 'Pale taupe', '78184a': 'Pansy purple', 'ffefd5': 'Papaya whip', 'aec6cf': 'Pastel blue', '836953': 'Pastel brown', 'cfcfc4': 'Pastel gray', '77dd77': 'Pastel green', 'f49ac2': 'Pastel magenta', 'ffb347': 'Pastel orange', 'dea5a4': 'Pastel pink', 'b39eb5': 'Pastel purple', 'ff6961': 'Pastel red', 'cb99c9': 'Pastel violet', 'fdfd96': 'Pastel yellow', '800080': ['Patriarch', 'Purple'], 'ffe5b4': 'Peach', 'ffcc99': 'Peach-orange', 'ffdab9': 'Peach puff', 'fadfad': 'Peach-yellow', 'd1e231': 'Pear', 'eae0c8': 'Pearl', '88d8c0': 'Pearl Aqua', 'b768a2': 'Pearly purple', 'e6e200': 'Peridot', '1c39bb': 'Persian blue', '00a693': 'Persian green', '32127a': 'Persian indigo', 'd99058': 'Persian orange', 'f77fbe': 'Persian pink', '701c1c': ['Persian plum', 'Prune'], 'cc3333': 'Persian red', 'fe28a2': 'Persian rose', 'ec5800': 'Persimmon', 'cd853f': 'Peru', 'df00ff': ['Phlox', 'Psychedelic purple'], '000f89': 'Phthalo blue', '123524': 'Phthalo green', 'c30b4e': 'Pictorial carmine', 'fddde6': 'Piggy pink', '01796f': 'Pine green', 'ffc0cb': 'Pink', 'ffddf4': 'Pink lace', 'e7accf': 'Pink pearl', 'f78fa7': 'Pink Sherbet', '93c572': 'Pistachio', 'e5e4e2': 'Platinum', '8e4585': 'Plum (traditional)', 'ff5a36': 'Portland Orange', 'b0e0e6': 'Powder blue', 'ff8f00': 'Princeton orange', '003153': 'Prussian blue', 'cc8899': 'Puce', 'ff7518': 'Pumpkin', '9f00c5': 'Purple (Munsell)', 'a020f0': ['Purple (X11)', 'Veronica'], '69359c': 'Purple Heart', '9678b6': 'Purple mountain majesty', 'fe4eda': 'Purple pizzazz', '50404d': 'Purple taupe', '51484f': 'Quartz', '436b95': 'Queen blue', 'e8ccd7': 'Queen pink', 'ff355e': 'Radical Red', 'fbab60': 'Rajah', 'e30b5d': 'Raspberry', 'e25098': 'Raspberry pink', '826644': 'Raw umber', 'ff33cc': 'Razzle dazzle rose', 'e3256b': 'Razzmatazz', '8d4e85': 'Razzmic Berry', 'ff0000': 'Red', 'f2003c': 'Red (Munsell)', 'c40233': 'Red (NCS)', 'ed1c24': 'Red (pigment)', 'fe2712': 'Red (RYB)', '860111': 'Red devil', 'ff5349': 'Red-orange', 'ab4e52': ['Redwood', 'Rose vale'], '522d80': 'Regalia', '002387': 'Resolution blue', '777696': 'Rhythm', '004040': 'Rich black', 'f1a7fe': 'Rich brilliant lavender', '0892d0': 'Rich electric blue', 'a76bcf': 'Rich lavender', 'b666d2': 'Rich lilac', '414833': 'Rifle green', '00cccc': 'Robin egg blue', '8a7f80': 'Rocket metallic', '838996': 'Roman silver', 'f9429e': 'Rose bonbon', '674846': 'Rose ebony', 'b76e79': 'Rose gold', 'ff66cc': 'Rose pink', 'aa98a9': 'Rose quartz', '905d5d': 'Rose taupe', '65000b': 'Rosewood', 'd40000': 'Rosso corsa', 'bc8f8f': 'Rosy brown', '0038a8': 'Royal azure', '002366': 'Royal blue (traditional)', '4169e1': 'Royal blue', 'ca2c92': 'Royal fuchsia', '7851a9': 'Royal purple', 'ce4676': 'Ruber', 'd10056': 'Rubine red', 'e0115f': 'Ruby', '9b111e': 'Ruby red', 'ff0028': 'Ruddy', 'bb6528': 'Ruddy brown', 'e18e96': 'Ruddy pink', 'a81c07': 'Rufous', '80461b': 'Russet', 'b7410e': 'Rust', 'da2c43': 'Rusty red', '8b4513': 'Saddle brown', 'ff6700': 'Safety orange (blaze orange)', 'f4c430': 'Saffron', '23297a': 'St. Patrick\'s blue', 'ff8c69': 'Salmon', 'ff91a4': 'Salmon pink', 'ecd540': 'Sandstorm', 'f4a460': 'Sandy brown', '92000a': 'Sangria', '507d2a': 'Sap green', '0f52ba': 'Sapphire', 'cba135': 'Satin sheen gold', 'ff2400': 'Scarlet', 'fd0e35': ['Scarlet (Crayola)', 'Tractor red'], 'ffd800': 'School bus yellow', '76ff7a': 'Screamin\' Green', '006994': 'Sea blue', '2e8b57': 'Sea green', '321414': 'Seal brown', 'fff5ee': 'Seashell', 'ffba00': 'Selective yellow', '704214': 'Sepia', '8a795d': 'Shadow', 'ffcff1': 'Shampoo', '009e60': 'Shamrock green', '8fd400': 'Sheen Green', 'd98695': 'Shimmering Blush', 'fc0fc0': 'Shocking pink', 'ff6fff': ['Shocking pink (Crayola)', 'Ultra pink'], 'c0c0c0': 'Silver', 'acacac': 'Silver chalice', 'c4aead': 'Silver pink', 'bfc1c2': 'Silver sand', 'cb410b': 'Sinopia', '007474': 'Skobeloff', '87ceeb': 'Sky blue', 'cf71af': 'Sky magenta', '6a5acd': 'Slate blue', '708090': 'Slate gray', 'c84186': 'Smitten', '738276': 'Smoke', '933d41': 'Smokey topaz', '100c08': 'Smoky black', 'fffafa': 'Snow', 'cec8ef': 'Soap', '757575': 'Sonic silver', '1d2951': 'Space cadet', '80755a': 'Spanish bistre', 'd10047': 'Spanish carmine', 'e51a4c': 'Spanish crimson', 'e86100': 'Spanish orange', '00aae4': 'Spanish sky blue', '0fc0fc': 'Spiro Disco Ball', 'a7fc00': 'Spring bud', '007bbb': 'Star command blue', '4682b4': 'Steel blue', 'cc3366': 'Steel pink', '4f666a': 'Stormcloud', 'e4d96f': 'Straw', 'fc5a8d': 'Strawberry', 'ffcc33': 'Sunglow', 'cf6ba9': 'Super pink', 'd2b48c': 'Tan', 'f94d00': 'Tangelo', 'f28500': 'Tangerine', 'ffcc00': ['Tangerine yellow', 'USC Gold'], '8b8589': 'Taupe gray', 'd0f0c0': 'Tea green', '008080': 'Teal', '367588': 'Teal blue', '99e6b3': 'Teal deer', '00827f': 'Teal green', 'cf3476': 'Telemagenta', 'cd5700': 'Tenné (Tawny)', 'e2725b': 'Terra cotta', 'd8bfd8': 'Thistle', 'fc89ac': 'Tickle Me Pink', '0abab5': 'Tiffany Blue', 'e08d3c': 'Tiger\'s eye', 'dbd7d2': 'Timberwolf', 'eee600': 'Titanium yellow', 'ff6347': 'Tomato', '746cc0': 'Toolbox', 'ffc87c': 'Topaz', '00755e': 'Tropical rain forest', '0073cf': 'True Blue', '417dc1': 'Tufts Blue', 'ff878d': 'Tulip', 'deaa88': 'Tumbleweed', 'b57281': 'Turkish rose', '30d5c8': 'Turquoise', '00ffef': 'Turquoise blue', 'a0d6b4': 'Turquoise green', '7c4848': 'Tuscan red', 'c09999': 'Tuscany', '8a496b': 'Twilight lavender', '66023c': 'Tyrian purple', '0033aa': 'UA blue', 'd9004c': 'UA red', '8878c3': 'Ube', '536895': 'UCLA Blue', 'ffb300': 'UCLA Gold', '3cd070': 'UFO Green', '120a8f': 'Ultramarine', '4166f5': 'Ultramarine blue', '635147': 'Umber', 'ffddca': 'Unbleached silk', '5b92e5': 'United Nations blue', 'b78727': 'University of California Gold', '7b1113': 'UP Maroon', 'ae2029': 'Upsdell red', 'e1ad21': 'Urobilin', '004f98': 'USAFA blue', 'f77f00': 'University of Tennessee Orange', 'd3003f': 'Utah Crimson', 'f3d9df': 'Vanilla ice', 'c5b358': 'Vegas gold', 'c80815': 'Venetian red', '43b3ae': 'Verdigris', '7f00ff': 'Violet', '8601af': 'Violet (RYB)', '324ab2': 'Violet-blue', 'f75394': 'Violet-red', '40826d': 'Viridian', '922724': 'Vivid auburn', '9f1d35': 'Vivid burgundy', 'da1d81': 'Vivid cerise', 'cc00ff': 'Vivid orchid', '00ccff': 'Vivid sky blue', 'ffa089': 'Vivid tangerine', '9f00ff': 'Vivid violet', '004242': 'Warm black', 'a4f4f9': 'Waterspout', '645452': 'Wenge', 'f5deb3': 'Wheat', 'ffffff': 'White', 'f5f5f5': 'White smoke', 'a2add0': 'Wild blue yonder', 'd77a02': 'Wild orchid', 'ff43a4': 'Wild Strawberry', 'fc6c85': 'Wild Watermelon', 'ae6838': 'Windsor tan', '722f37': 'Wine', 'c9a0dc': 'Wisteria', '738678': 'Xanadu', '0f4d92': 'Yale Blue', '1c2841': 'Yankees blue', 'ffff00': 'Yellow', 'efcc00': 'Yellow (Munsell)', 'ffd300': 'Yellow (NCS)', 'fefe33': 'Yellow (RYB)', '9acd32': 'Yellow-green', 'ffae42': 'Yellow Orange', 'fff000': 'Yellow rose', '0014a8': 'Zaffre', '2c1608': 'Zinnwaldite brown' }; /** * Get a list of colors with the HTML name as the key and hex as value * @static * @param {Boolean} websafe If true only use web safe colors * @returns {Object.<String, String>} */ Color.getNamedList = function(websafe) { var list = !websafe ? this.list : this.webSafe; var out = {}; var i = 0; var len; for (var hex in list) { if (Type.isString(list[hex])) { out[list[hex]] = hex; } else if (Type.isArray(list[hex])) { len = list[hex].length; for (i = 0; i < len; ++i) { out[list[hex][i]] = hex; } } } return out; }; /** * List of hex colors and their name equivalent * @static * @constant * @type {Object.<String, String>} */ Color.listNamed = Color.getNamedList(); /** * List of web safe hex colors and their name equivalent * @static * @constant * @type {Object.<String, String>} */ Color.webSafeNamed = Color.getNamedList(true); /** * Attempts to get the color's type * @static * @param {Object|String} color * @returns {String} */ Color.getType = function(color) { if (color) { if (Type.isString(color)) { if (!Util.empty(this.listNamed[color.toLowerCase()])) { return this.NAMED; } else if (this.regex.hex.test(color)) { return this.HEX; } else if (this.regex.RGB.test(color)) { return this.RGB; } else if (this.regex.RGBA.test(color)) { return this.RGBA; } else if (this.regex.HSL.test(color)) { return this.HSL; } else if (this.regex.HSLA.test(color)) { return this.HSLA; } } else { // Long in the tooth, but "instanceof" is very quick vs. Type.getType() if (color instanceof RGB) { return this.RGB; } else if (color instanceof RGBA) { return this.RGBA; } else if (color instanceof RYB) { return this.RYB; } else if (color instanceof Hex) { return this.HEX; } else if (color instanceof HSL) { return this.HSL; } else if (color instanceof HSLA) { return this.HSLA; } else if (color instanceof HSV) { return this.HSV; } else if (color instanceof XYZ) { return this.XYZ; } else if (color instanceof xyY) { return this.XYY; } else if (color instanceof CIELab) { return this.CIELAB; } else if (color instanceof CIELuv) { return this.CIELUV; } else if (color instanceof CIELCH) { return this.CIELCH; } else if (color instanceof HunterLab) { return this.HUNTERLAB; } else if (color instanceof CMYK) { return this.CMYK; } else if (color instanceof CMY) { return this.CMY; } else if (color instanceof YIQ) { return this.YIQ; } else if (color instanceof YUV) { return this.YUV; } else if (color instanceof YDbDr) { return this.YDBDR; } else if (color instanceof YCbCr) { return this.YCBCR; } else if (color instanceof YPbPr) { return this.YPBPR; } } } return undefined; }; /** * Attempts to convert the color to a given type * @static * @param {Object|String} color * @param {String} type The color type to return * @returns {Object|String} */ Color.toType = function(color, type) { if (color && type) { switch (type) { case this.NAMED: color = color.toLowerCase().substr(1); return !Util.empty(this.list[color]) ? this.list[color] : undefined; case this.HEX: case this.RGB: case this.RGBA: case this.RYB: case this.HSL: case this.HSLA: case this.HSV: case this.XYZ: case this.XYY: case this.CIELAB: case this.CIELUV: case this.CIELCH: case this.HUNTERLAB: case this.CMYK: case this.CMY: case this.YIQ: case this.YUV: case this.YDBDR: case this.YCBCR: case this.YPBPR: return toColorSpace(color, type); } } return null; }; /** * Checks if color passed is valid color * @static * @param {Object|String} color * @returns {Boolean} */ Color.isValid = function(color) { return color && this.getType(color) ? true : false; }; /** * Checks if color passed is valid CSS color * @static * @param {Object|String} color * @returns {Boolean} */ Color.isValidCSS = function(color) { if (color) { color = this.getType(color); if (color) { return CSS.colorTypes.hasOwnProperty(color); } } return false; }; /** * Checks if type passed is valid color type * @static * @param {String} type * @returns {Boolean} */ Color.isValidType = function(type) { return type ? this.types.hasOwnProperty(type) : false; }; /** * Checks if type passed is valid CSS color type * @static * @param {String} type * @returns {Boolean} */ Color.isValidCSSType = function(type) { return type ? CSS.colorTypes.hasOwnProperty(type) : false; }; /** * Checks if the color is grayscale * @static * @param {Object} color * @returns {Boolean|Null} Null if invalid color */ Color.isGrayscale = function(color) { if (color) { color = new RGB(color); if (color && color.isSet()) { return color.red === color.green && color.red === color.blue; } } return null; }; /** * "Compile" Styles to CSS * @param {Array} styles Style array * @returns {String} */ function toCSS(styles) { styles = styles === undefined ? Styles : styles; if (Type.isArray(styles)) { var len = styles.length; if (len > 0) { var CSS = branding ? '/**\n * Generated by Style.js ' + Style.getVersion() + ', ' + new Date() + '\n */\n' : ''; for (var i = 0; i < len; ++i) { CSS += styles[i] + '\n\n'; } return CSS.slice(0, -2); } } return ''; } $.toCSS = toCSS; /** * Style class / wrapper, populates Styles array * @constructor * @param {Object|String} style Style object / string * @param {Array} styles Array to bind style to (non-global) */ function Style(style, styles) { if (!Util.empty(style)) { this.self = style; if (styles === undefined) { Styles.push(this); } else if (Type.isArray(styles)) { styles.push(this); } } } $.Style = Style; /** * Returns version of library * @static * @returns {String} */ Style.getVersion = function() { return VERSION_MAJOR + '.' + VERSION_MINOR + '.' + VERSION_PATCH; }; /** * Clear the Styles array * @static */ Style.clear = function() { Styles = []; }; /** * Disable Style.js branding * @static */ Style.disableBranding = function() { branding = false; }; /** * Enable Style.js branding * @static */ Style.enableBranding = function() { branding = false; }; /** * Compile to a object with a single dimension of CSS properties * @param {Object} obj Object to reduce to CSS properties * @param {Object} output The current working output * @param {String} parent Parent selector * @param {String} child Child selector * @returns {Object} */ Style.prototype.compile = function(obj, output, parent, child) { if (Type.isString(this.self)) { return this.self; } if (obj === undefined) { obj = this.self; } // Initiate output object if undefined if (output === undefined) { output = {}; } // Top level definition if (parent === undefined) { for (var i in obj) { if (!Type.isFunction(obj[i])) { this.compileObject(obj[i], output, i); } } } // Child definition else { this.compileObject(obj, output, parent, child); } return output; }; /** * Compile to a object with a single dimension of CSS properties * @param {Object} obj Object to reduce to CSS properties * @param {Object} output The current working output * @param {String} parent Parent selector * @param {String} child Child selector */ Style.prototype.compileObject = function(obj, output, parent, child) { var compile = false; if (child !== undefined) { if (Type.isString(child)) { var len = child.length - 1; var firstChar = child.charAt(0); var lastChar = child.charAt(len); if (!(firstChar === '$' && lastChar === '$')) { if (lastChar !== '$') { // Add pseudo class child = firstChar === '$' ? ':' + child.substr(1) : ' ' + child; // Add hierarchy to CSS selectors parent = parent.replace(/\s*,\s*/g, child + ', ') + child.replace(/\s*,\s*/g, ', ' + parent + ' '); } else { child = child.substr(0, len); // Add hierarchy to CSS selectors parent = child + ' ' + parent.replace(/\s*,\s*/g, ', ' + child); } compile = true; } } } else { compile = true; } if (compile) { var type; for (var x in obj) { if ((type = Type.getType(obj[x])) !== 'function') { if (!output[parent]) { output[parent] = []; } if (type === 'string' || Color.isValidCSSType(type)) { output[parent].push(x.replace(/\_/g, '-') + ": " + obj[x]); } else if (type === 'number') { output[parent].push(x.replace(/\_/g, '-') + ": " + obj[x] + (obj[x] !== 0 ? defaultUnit : '')); } else if (type === 'array') { for (var y in obj[x]) { if ((type = Type.getType(obj[x][y])) !== 'function') { if (type === 'string' || Color.isValidCSSType(type)) { output[parent].push(x.replace(/\_/g, '-') + ": " + obj[x][y]); } else if (type === 'number') { output[parent].push(x.replace(/\_/g, '-') + ": " + obj[x][y] + (obj[x][y] !== 0 ? defaultUnit : '')); } } } } e