LCOV - code coverage report
Current view: top level - core/geom - SPColor.cc (source / functions) Hit Total Coverage
Test: coverage.info Lines: 524 571 91.8 %
Date: 2024-05-12 00:16:13 Functions: 90 90 100.0 %

          Line data    Source code
       1             : /**
       2             : Copyright (c) 2008-2010 Ricardo Quesada
       3             : Copyright (c) 2010-2012 cocos2d-x.org
       4             : Copyright (c) 2011      Zynga Inc.
       5             : Copyright (c) 2013-2014 Chukong Technologies Inc.
       6             : Copyright (c) 2016-2022 Roman Katuntsev <sbkarr@stappler.org>
       7             : Copyright (c) 2023 Stappler LLC <admin@stappler.dev>
       8             : 
       9             : Permission is hereby granted, free of charge, to any person obtaining a copy
      10             : of this software and associated documentation files (the "Software"), to deal
      11             : in the Software without restriction, including without limitation the rights
      12             : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
      13             : copies of the Software, and to permit persons to whom the Software is
      14             : furnished to do so, subject to the following conditions:
      15             : 
      16             : The above copyright notice and this permission notice shall be included in
      17             : all copies or substantial portions of the Software.
      18             : 
      19             : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      20             : IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      21             : FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
      22             : AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      23             : LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      24             : OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
      25             : THE SOFTWARE.
      26             : **/
      27             : 
      28             : #include "SPColor.h"
      29             : #include "SPString.h"
      30             : 
      31             : namespace STAPPLER_VERSIONIZED stappler::geom {
      32             : 
      33             : #define MD_COLOR_SPEC_COMPONENT(Name, Id, Value, Index, Group) \
      34             :         Color Color::Name ## _ ## Id(0x ## Value, Group * 16 + Index); \
      35             : 
      36             : #define MD_COLOR_SPEC_BASE_DEFINE(Name, Group, b50, b100, b200, b300, b400, b500, b600, b700, b800, b900 ) \
      37             :         MD_COLOR_SPEC_COMPONENT(Name, 50, b50, 0, Group) \
      38             :         MD_COLOR_SPEC_COMPONENT(Name, 100, b100, 1, Group) \
      39             :         MD_COLOR_SPEC_COMPONENT(Name, 200, b200, 2, Group) \
      40             :         MD_COLOR_SPEC_COMPONENT(Name, 300, b300, 3, Group) \
      41             :         MD_COLOR_SPEC_COMPONENT(Name, 400, b400, 4, Group) \
      42             :         MD_COLOR_SPEC_COMPONENT(Name, 500, b500, 5, Group) \
      43             :         MD_COLOR_SPEC_COMPONENT(Name, 600, b600, 6, Group) \
      44             :         MD_COLOR_SPEC_COMPONENT(Name, 700, b700, 7, Group) \
      45             :         MD_COLOR_SPEC_COMPONENT(Name, 800, b800, 8, Group) \
      46             :         MD_COLOR_SPEC_COMPONENT(Name, 900, b900, 9, Group)
      47             : 
      48             : #define MD_COLOR_SPEC_ACCENT_DEFINE(Name, Group, a100, a200, a400, a700 ) \
      49             :         MD_COLOR_SPEC_COMPONENT(Name, A100, a100, 10, Group) \
      50             :         MD_COLOR_SPEC_COMPONENT(Name, A200, a200, 11, Group) \
      51             :         MD_COLOR_SPEC_COMPONENT(Name, A400, a400, 12, Group) \
      52             :         MD_COLOR_SPEC_COMPONENT(Name, A700, a700, 13, Group)
      53             : 
      54             : #define MD_COLOR_SPEC_DEFINE(Name, Group, b50, b100, b200, b300, b400, b500, b600, b700, b800, b900, a100, a200, a400, a700) \
      55             :         MD_COLOR_SPEC_BASE_DEFINE(Name, Group, b50, b100, b200, b300, b400, b500, b600, b700, b800, b900) \
      56             :         MD_COLOR_SPEC_ACCENT_DEFINE(Name, Group, a100, a200, a400, a700)
      57             : 
      58             : namespace table {
      59             : 
      60             : static struct ColorDataTable {
      61             :         uint32_t value;
      62             :         uint16_t index;
      63             :         uint32_t hash;
      64             :         char str[16];
      65             : } data[256] = {
      66             :         { 0xffebee, 0x000, 0x923cbb49, "Red50" },
      67             :         { 0xffcdd2, 0x001, 0x76a5549f, "Red100" },
      68             :         { 0xef9a9a, 0x002, 0x049de544, "Red200" },
      69             :         { 0xe57373, 0x003, 0x0aa02d4d, "Red300" },
      70             :         { 0xef5350, 0x004, 0x78988bd2, "Red400" },
      71             :         { 0xf44336, 0x005, 0x7e9ad3db, "Red500" },
      72             :         { 0xe53935, 0x006, 0x6c93fbe0, "Red600" },
      73             :         { 0xd32f2f, 0x007, 0x729643e9, "Red700" },
      74             :         { 0xc62828, 0x008, 0x80b6adbe, "Red800" },
      75             :         { 0xb71c1c, 0x009, 0x86b8f5a7, "Red900" },
      76             :         { 0xff8a80, 0x00a, 0x90873a24, "RedA100" },
      77             :         { 0xff5252, 0x00b, 0x028ea97f, "RedA200" },
      78             :         { 0xff1744, 0x00c, 0xfe7f9849, "RedA400" },
      79             :         { 0xd50000, 0x00d, 0x8482aa32, "RedA700" },
      80             :         { 0xfce4ec, 0x010, 0x4b45fd26, "Pink50" },
      81             :         { 0xf8bbd0, 0x011, 0x1d373a26, "Pink100" },
      82             :         { 0xf48fb1, 0x012, 0x3735245d, "Pink200" },
      83             :         { 0xf06292, 0x013, 0xb13212d4, "Pink300" },
      84             :         { 0xec407a, 0x014, 0xab2fcaeb, "Pink400" },
      85             :         { 0xe91e63, 0x015, 0xa52d82e2, "Pink500" },
      86             :         { 0xd81b60, 0x016, 0x9f2b3af9, "Pink600" },
      87             :         { 0xc2185b, 0x017, 0x19282970, "Pink700" },
      88             :         { 0xad1457, 0x018, 0xb34decb7, "Pink800" },
      89             :         { 0x880e4f, 0x019, 0x2d4adace, "Pink900" },
      90             :         { 0xff80ab, 0x01a, 0x3f00b37b, "PinkA100" },
      91             :         { 0xff4081, 0x01b, 0xacf91180, "PinkA200" },
      92             :         { 0xf50057, 0x01c, 0xb10822b6, "PinkA400" },
      93             :         { 0xc51162, 0x01d, 0x4b05436d, "PinkA700" },
      94             :         { 0xf3e5f5, 0x020, 0x054596d0, "Purple50" },
      95             :         { 0xe1bee7, 0x021, 0xb4965324, "Purple100" },
      96             :         { 0xce93d8, 0x022, 0x269dc27f, "Purple200" },
      97             :         { 0xba68c8, 0x023, 0x209b7a76, "Purple300" },
      98             :         { 0xab47bc, 0x024, 0x228eb149, "Purple400" },
      99             :         { 0x9c27b0, 0x025, 0x1c8c6940, "Purple500" },
     100             :         { 0x8e24aa, 0x026, 0xae940b3b, "Purple600" },
     101             :         { 0x7b1fa2, 0x027, 0xa891c332, "Purple700" },
     102             :         { 0x6a1b9a, 0x028, 0x2aacd315, "Purple800" },
     103             :         { 0x4a148c, 0x029, 0x24aa8b2c, "Purple900" },
     104             :         { 0xea80fc, 0x02a, 0x5d994875, "PurpleA100" },
     105             :         { 0xe040fb, 0x02b, 0xe39c59fe, "PurpleA200" },
     106             :         { 0xd500f9, 0x02c, 0xdf8d48c8, "PurpleA400" },
     107             :         { 0xaa00ff, 0x02d, 0x5194b803, "PurpleA700" },
     108             :         { 0xede7f6, 0x030, 0x7f6f7c22, "DeepPurple50" },
     109             :         { 0xd1c4e9, 0x031, 0x4676b272, "DeepPurple100" },
     110             :         { 0xb39ddb, 0x032, 0xc073a089, "DeepPurple200" },
     111             :         { 0x9575cd, 0x033, 0xba715880, "DeepPurple300" },
     112             :         { 0x7e57c2, 0x034, 0xc482b1bf, "DeepPurple400" },
     113             :         { 0x673ab7, 0x035, 0xbe8069b6, "DeepPurple500" },
     114             :         { 0x5e35b1, 0x036, 0x587d8a6d, "DeepPurple600" },
     115             :         { 0x512da8, 0x037, 0x527b4264, "DeepPurple700" },
     116             :         { 0x4527a0, 0x038, 0x3c8c68e3, "DeepPurple800" },
     117             :         { 0x311b92, 0x039, 0x568a531a, "DeepPurple900" },
     118             :         { 0xb388ff, 0x03a, 0xdc75aabf, "DeepPurpleA100" },
     119             :         { 0x7c4dff, 0x03b, 0x6a6e3b64, "DeepPurpleA200" },
     120             :         { 0x651fff, 0x03c, 0x5e69ab72, "DeepPurpleA400" },
     121             :         { 0x6200ea, 0x03d, 0xd8669989, "DeepPurpleA700" },
     122             :         { 0xe8eaf6, 0x040, 0xdcf7027c, "Indigo50" },
     123             :         { 0xc5cae9, 0x041, 0xbcceffa0, "Indigo100" },
     124             :         { 0x9fa8da, 0x042, 0xced5d79b, "Indigo200" },
     125             :         { 0x7986cb, 0x043, 0xc8d38f92, "Indigo300" },
     126             :         { 0x5c6bc0, 0x044, 0x5adb310d, "Indigo400" },
     127             :         { 0x3f51b5, 0x045, 0x54d8e904, "Indigo500" },
     128             :         { 0x3949ab, 0x046, 0xc6e0585f, "Indigo600" },
     129             :         { 0x303f9f, 0x047, 0x40dd46d6, "Indigo700" },
     130             :         { 0x283593, 0x048, 0xd2e4e8b1, "Indigo800" },
     131             :         { 0x1a237e, 0x049, 0xcce2a048, "Indigo900" },
     132             :         { 0x8c9eff, 0x04a, 0x847da209, "IndigoA100" },
     133             :         { 0x536dfe, 0x04b, 0x0a80b3f2, "IndigoA200" },
     134             :         { 0x3d5afe, 0x04c, 0x168543e4, "IndigoA400" },
     135             :         { 0x304ffe, 0x04d, 0x888cb33f, "IndigoA700" },
     136             :         { 0xe3f2fd, 0x050, 0xfece83ca, "Blue50" },
     137             :         { 0xbbdefb, 0x051, 0x710fbf8a, "Blue100" },
     138             :         { 0x90caf9, 0x052, 0x6b0d7781, "Blue200" },
     139             :         { 0x64b5f6, 0x053, 0x650b2f98, "Blue300" },
     140             :         { 0x42a5f5, 0x054, 0x6f1c88b7, "Blue400" },
     141             :         { 0x2196f3, 0x055, 0xe91976ce, "Blue500" },
     142             :         { 0x1e88e5, 0x056, 0xe3172ec5, "Blue600" },
     143             :         { 0x1976d2, 0x057, 0xdd14e6dc, "Blue700" },
     144             :         { 0x1565c0, 0x058, 0x66fe66eb, "Blue800" },
     145             :         { 0x0d47a1, 0x059, 0x60fc1ee2, "Blue900" },
     146             :         { 0x82b1ff, 0x05a, 0xa0daaf87, "BlueA100" },
     147             :         { 0x448aff, 0x05b, 0x8ed3d7ac, "BlueA200" },
     148             :         { 0x2979ff, 0x05c, 0x22ceb05a, "BlueA400" },
     149             :         { 0x2962ff, 0x05d, 0x1ccc6851, "BlueA700" },
     150             :         { 0xe1f5fe, 0x060, 0xfd10b1d4, "LightBlue50" },
     151             :         { 0xb3e5fc, 0x061, 0xbd3e3948, "LightBlue100" },
     152             :         { 0x81d4fa, 0x062, 0x2f45a883, "LightBlue200" },
     153             :         { 0x4fc3f7, 0x063, 0xc942c9ba, "LightBlue300" },
     154             :         { 0x29b6f6, 0x064, 0x3b4a38f5, "LightBlue400" },
     155             :         { 0x03a9f4, 0x065, 0x3547f08c, "LightBlue500" },
     156             :         { 0x039be5, 0x066, 0xc74f9267, "LightBlue600" },
     157             :         { 0x0288d1, 0x067, 0xc14d4a7e, "LightBlue700" },
     158             :         { 0x0277bd, 0x068, 0xb32ce0a9, "LightBlue800" },
     159             :         { 0x01579b, 0x069, 0xad2a98a0, "LightBlue900" },
     160             :         { 0x80d8ff, 0x06a, 0x5b962f01, "LightBlueA100" },
     161             :         { 0x40c4ff, 0x06b, 0x6198770a, "LightBlueA200" },
     162             :         { 0x00b0ff, 0x06c, 0xcd9d9e5c, "LightBlueA400" },
     163             :         { 0x0091ea, 0x06d, 0x5fa54037, "LightBlueA700" },
     164             :         { 0xe0f7fa, 0x070, 0xecdfdf13, "Cyan50" },
     165             :         { 0xb2ebf2, 0x071, 0x8f7614bd, "Cyan100" },
     166             :         { 0x80deea, 0x072, 0xf578f386, "Cyan200" },
     167             :         { 0x4dd0e1, 0x073, 0xfb7b3b8f, "Cyan300" },
     168             :         { 0x26c6da, 0x074, 0xf169e2d0, "Cyan400" },
     169             :         { 0x00bcd4, 0x075, 0xf76c2ad9, "Cyan500" },
     170             :         { 0x00acc1, 0x076, 0xfd6e72c2, "Cyan600" },
     171             :         { 0x0097a7, 0x077, 0x8371844b, "Cyan700" },
     172             :         { 0x00838f, 0x078, 0x79873b3c, "Cyan800" },
     173             :         { 0x006064, 0x079, 0xff8a4ca5, "Cyan900" },
     174             :         { 0x84ffff, 0x07a, 0xdc9a481e, "CyanA100" },
     175             :         { 0x18ffff, 0x07b, 0xd6980015, "CyanA200" },
     176             :         { 0x00e5ff, 0x07c, 0x4a92a6a3, "CyanA400" },
     177             :         { 0x00b8d4, 0x07d, 0xd88b3768, "CyanA700" },
     178             :         { 0xe0f2f1, 0x080, 0x257885fc, "Teal50" },
     179             :         { 0xb2dfdb, 0x081, 0x60b10220, "Teal100" },
     180             :         { 0x80cbc4, 0x082, 0x72b7da1b, "Teal200" },
     181             :         { 0x4db6ac, 0x083, 0x6cb59212, "Teal300" },
     182             :         { 0x26a69a, 0x084, 0xfebd338d, "Teal400" },
     183             :         { 0x009688, 0x085, 0xf8baeb84, "Teal500" },
     184             :         { 0x00897b, 0x086, 0x6ac25adf, "Teal600" },
     185             :         { 0x00796b, 0x087, 0xe4bf4956, "Teal700" },
     186             :         { 0x00695c, 0x088, 0x76c6eb31, "Teal800" },
     187             :         { 0x004d40, 0x089, 0x70c4a2c8, "Teal900" },
     188             :         { 0xa7ffeb, 0x08a, 0x01479189, "TealA100" },
     189             :         { 0x64ffda, 0x08b, 0x874aa372, "TealA200" },
     190             :         { 0x1de9b6, 0x08c, 0x934f3364, "TealA400" },
     191             :         { 0x00bfa5, 0x08d, 0x0556a2bf, "TealA700" },
     192             :         { 0xe8f5e9, 0x090, 0x8209d369, "Green50" },
     193             :         { 0xc8e6c9, 0x091, 0x968185bf, "Green100" },
     194             :         { 0xa5d6a7, 0x092, 0x247a1664, "Green200" },
     195             :         { 0x81c784, 0x093, 0x2a7c5e6d, "Green300" },
     196             :         { 0x66bb6a, 0x094, 0x18758672, "Green400" },
     197             :         { 0x4caf50, 0x095, 0x1e77ce7b, "Green500" },
     198             :         { 0x43a047, 0x096, 0x8c702c80, "Green600" },
     199             :         { 0x388e3c, 0x097, 0x92727489, "Green700" },
     200             :         { 0x2e7d32, 0x098, 0xa092de5e, "Green800" },
     201             :         { 0x1b5e20, 0x099, 0xa6952647, "Green900" },
     202             :         { 0xb9f6ca, 0x09a, 0x1e7bbc84, "GreenA100" },
     203             :         { 0x69f0ae, 0x09b, 0x90832bdf, "GreenA200" },
     204             :         { 0x00e676, 0x09c, 0x8c741b29, "GreenA400" },
     205             :         { 0x00c853, 0x09d, 0x92766312, "GreenA700" },
     206             :         { 0xf1f8e9, 0x0a0, 0x1b4f6967, "LightGreen50" },
     207             :         { 0xdcedc8, 0x0a1, 0xecf935d1, "LightGreen100" },
     208             :         { 0xc5e1a5, 0x0a2, 0xf2fb7dda, "LightGreen200" },
     209             :         { 0xaed581, 0x0a3, 0xd8fd93a3, "LightGreen300" },
     210             :         { 0x9ccc65, 0x0a4, 0x5f00a52c, "LightGreen400" },
     211             :         { 0x8bc34a, 0x0a5, 0x6502ed15, "LightGreen500" },
     212             :         { 0x7cb342, 0x0a6, 0x6b05351e, "LightGreen600" },
     213             :         { 0x689f38, 0x0a7, 0x71077d07, "LightGreen700" },
     214             :         { 0x558b2f, 0x0a8, 0x56e28340, "LightGreen800" },
     215             :         { 0x33691e, 0x0a9, 0x5ce4cb49, "LightGreen900" },
     216             :         { 0xccff90, 0x0aa, 0xe23fc0da, "LightGreenA100" },
     217             :         { 0xb2ff59, 0x0ab, 0xdc3d78d1, "LightGreenA200" },
     218             :         { 0x76ff03, 0x0ac, 0x604bc007, "LightGreenA400" },
     219             :         { 0x64dd17, 0x0ad, 0x4e44e82c, "LightGreenA700" },
     220             :         { 0xf9fbe7, 0x0b0, 0xb0f07589, "Lime50" },
     221             :         { 0xf0f4c3, 0x0b1, 0x0b93875f, "Lime100" },
     222             :         { 0xe6ee9c, 0x0b2, 0x998c1804, "Lime200" },
     223             :         { 0xdce775, 0x0b3, 0x9f8e600d, "Lime300" },
     224             :         { 0xd4e157, 0x0b4, 0x0d86be92, "Lime400" },
     225             :         { 0xcddc39, 0x0b5, 0x1389069b, "Lime500" },
     226             :         { 0xc0ca33, 0x0b6, 0x01822ea0, "Lime600" },
     227             :         { 0xafb42b, 0x0b7, 0x078476a9, "Lime700" },
     228             :         { 0x9e9d24, 0x0b8, 0x15a4e07e, "Lime800" },
     229             :         { 0x827717, 0x0b9, 0x1ba72867, "Lime900" },
     230             :         { 0xf4ff81, 0x0ba, 0x36dac3e4, "LimeA100" },
     231             :         { 0xeeff41, 0x0bb, 0xa8e2333f, "LimeA200" },
     232             :         { 0xc6ff00, 0x0bc, 0xa4d32209, "LimeA400" },
     233             :         { 0xaeea00, 0x0bd, 0x2ad633f2, "LimeA700" },
     234             :         { 0xfffde7, 0x0c0, 0xea0669fa, "Yellow50" },
     235             :         { 0xfff9c4, 0x0c1, 0x6a0e53fa, "Yellow100" },
     236             :         { 0xfff59d, 0x0c2, 0x640c0bf1, "Yellow200" },
     237             :         { 0xfff176, 0x0c3, 0x5e09c388, "Yellow300" },
     238             :         { 0xffee58, 0x0c4, 0x681b1ca7, "Yellow400" },
     239             :         { 0xffeb3b, 0x0c5, 0x6218d4be, "Yellow500" },
     240             :         { 0xfdd835, 0x0c6, 0xdc15c335, "Yellow600" },
     241             :         { 0xfbc02d, 0x0c7, 0xd6137acc, "Yellow700" },
     242             :         { 0xf9a825, 0x0c8, 0x5ffcfadb, "Yellow800" },
     243             :         { 0xf57f17, 0x0c9, 0x59fab2d2, "Yellow900" },
     244             :         { 0xffff8d, 0x0ca, 0x2712fad7, "YellowA100" },
     245             :         { 0xffff00, 0x0cb, 0x950b597c, "YellowA200" },
     246             :         { 0xffea00, 0x0cc, 0xa906fbaa, "YellowA400" },
     247             :         { 0xffd600, 0x0cd, 0x2303ea21, "YellowA700" },
     248             :         { 0xfff8e1, 0x0d0, 0x7aa9e319, "Amber50" },
     249             :         { 0xffecb3, 0x0d1, 0xaa7a37af, "Amber100" },
     250             :         { 0xffe082, 0x0d2, 0x3872c854, "Amber200" },
     251             :         { 0xffd54f, 0x0d3, 0xbe75d9dd, "Amber300" },
     252             :         { 0xffca28, 0x0d4, 0x2c6e3862, "Amber400" },
     253             :         { 0xffc107, 0x0d5, 0x3270806b, "Amber500" },
     254             :         { 0xffb300, 0x0d6, 0xa068def0, "Amber600" },
     255             :         { 0xffa000, 0x0d7, 0x266bf079, "Amber700" },
     256             :         { 0xff8f00, 0x0d8, 0xb48b904e, "Amber800" },
     257             :         { 0xff6f00, 0x0d9, 0x3a8ea237, "Amber900" },
     258             :         { 0xffe57f, 0x0da, 0x9c707854, "AmberA100" },
     259             :         { 0xffd740, 0x0db, 0x0e77e7af, "AmberA200" },
     260             :         { 0xffc400, 0x0dc, 0x8a69a079, "AmberA400" },
     261             :         { 0xffab00, 0x0dd, 0x906be862, "AmberA700" },
     262             :         { 0xfff3e0, 0x0e0, 0xe9d03320, "Orange50" },
     263             :         { 0xffe0b2, 0x0e1, 0xcaca6534, "Orange100" },
     264             :         { 0xffcc80, 0x0e2, 0x3cd1d40f, "Orange200" },
     265             :         { 0xffb74d, 0x0e3, 0x36cf8c06, "Orange300" },
     266             :         { 0xffa726, 0x0e4, 0x38c2c359, "Orange400" },
     267             :         { 0xff9800, 0x0e5, 0x32c07b50, "Orange500" },
     268             :         { 0xfb8c00, 0x0e6, 0xc4c81ccb, "Orange600" },
     269             :         { 0xf57c00, 0x0e7, 0x3ec50b42, "Orange700" },
     270             :         { 0xef6c00, 0x0e8, 0x40e0e525, "Orange800" },
     271             :         { 0xe65100, 0x0e9, 0xbaddd3bc, "Orange900" },
     272             :         { 0xffd180, 0x0ea, 0x455a4d25, "OrangeA100" },
     273             :         { 0xffab40, 0x0eb, 0x4b5c952e, "OrangeA200" },
     274             :         { 0xff9100, 0x0ec, 0x474d8478, "OrangeA400" },
     275             :         { 0xff6d00, 0x0ed, 0xb954f3b3, "OrangeA700" },
     276             :         { 0xfbe9e7, 0x0f0, 0x60eb4716, "DeepOrange50" },
     277             :         { 0xffccbc, 0x0f1, 0x206a9ed6, "DeepOrange100" },
     278             :         { 0xffab91, 0x0f2, 0x3a68890d, "DeepOrange200" },
     279             :         { 0xff8a65, 0x0f3, 0x34664104, "DeepOrange300" },
     280             :         { 0xff7043, 0x0f4, 0xae632f9b, "DeepOrange400" },
     281             :         { 0xff5722, 0x0f5, 0xa860e792, "DeepOrange500" },
     282             :         { 0xf4511e, 0x0f6, 0xa25e9fa9, "DeepOrange600" },
     283             :         { 0xe64a19, 0x0f7, 0x9c5c57a0, "DeepOrange700" },
     284             :         { 0xd84315, 0x0f8, 0xb6815167, "DeepOrange800" },
     285             :         { 0xbf360c, 0x0f9, 0xb07f097e, "DeepOrange900" },
     286             :         { 0xff9e80, 0x0fa, 0x09b7420b, "DeepOrangeA100" },
     287             :         { 0xff6e40, 0x0fb, 0x77afa090, "DeepOrangeA200" },
     288             :         { 0xff3d00, 0x0fc, 0x7bbeb146, "DeepOrangeA400" },
     289             :         { 0xdd2c00, 0x0fd, 0x15bbd27d, "DeepOrangeA700" },
     290             :         { 0xefebe9, 0x100, 0x79194eec, "Brown50" },
     291             :         { 0xd7ccc8, 0x101, 0xf6cd53d0, "Brown100" },
     292             :         { 0xbcaaa4, 0x102, 0x88d4f54b, "Brown200" },
     293             :         { 0xa1887f, 0x103, 0x02d1e3c2, "Brown300" },
     294             :         { 0x8d6e63, 0x104, 0x94d985bd, "Brown400" },
     295             :         { 0x795548, 0x105, 0x8ed73db4, "Brown500" },
     296             :         { 0x6d4c41, 0x106, 0x00deac8f, "Brown600" },
     297             :         { 0x5d4037, 0x107, 0xfadc6486, "Brown700" },
     298             :         { 0x4e342e, 0x108, 0x0ce33ce1, "Brown800" },
     299             :         { 0x3e2723, 0x109, 0x06e0f4f8, "Brown900" },
     300             :         { 0xfafafa, 0x110, 0x4635a5e7, "Grey50" },
     301             :         { 0xf5f5f5, 0x111, 0xf56a7351, "Grey100" },
     302             :         { 0xeeeeee, 0x112, 0xfb6cbb5a, "Grey200" },
     303             :         { 0xe0e0e0, 0x113, 0xe16ed123, "Grey300" },
     304             :         { 0xbdbdbd, 0x114, 0x6771e2ac, "Grey400" },
     305             :         { 0x9e9e9e, 0x115, 0x6d742a95, "Grey500" },
     306             :         { 0x757575, 0x116, 0x7376729e, "Grey600" },
     307             :         { 0x616161, 0x117, 0x7978ba87, "Grey700" },
     308             :         { 0x424242, 0x118, 0x5f53c0c0, "Grey800" },
     309             :         { 0x212121, 0x119, 0x655608c9, "Grey900" },
     310             :         { 0xeceff1, 0x120, 0x669ef003, "BlueGrey50" },
     311             :         { 0xcfd8dc, 0x121, 0x273dbe6d, "BlueGrey100" },
     312             :         { 0xb0bec5, 0x122, 0x8d409db6, "BlueGrey200" },
     313             :         { 0x90a4ae, 0x123, 0x9342e5bf, "BlueGrey300" },
     314             :         { 0x78909c, 0x124, 0x89318c80, "BlueGrey400" },
     315             :         { 0x607d8b, 0x125, 0x8f33d489, "BlueGrey500" },
     316             :         { 0x546e7a, 0x126, 0x1536e672, "BlueGrey600" },
     317             :         { 0x455a64, 0x127, 0x1b392e7b, "BlueGrey700" },
     318             :         { 0x37474f, 0x128, 0x914fae6c, "BlueGrey800" },
     319             :         { 0x263238, 0x129, 0x9751f655, "BlueGrey900" },
     320             :         { 0xffffff, 0x130, 0x401e7178, "White" },
     321             :         { 0x000000, 0x131, 0x5e8e7be2, "Black" },
     322             : };
     323             : 
     324             : static struct ColorIndexValue {
     325             :         uint32_t value;
     326             :         uint8_t idx;
     327             : } valueIndex[256] = {
     328             :         { 0x000000, 0xff }, { 0x004d40, 0x79 }, { 0x006064, 0x6b }, { 0x00695c, 0x78 }, { 0x00796b, 0x77 }, { 0x00838f, 0x6a }, { 0x00897b, 0x76 }, { 0x0091ea, 0x61 },
     329             :         { 0x009688, 0x75 }, { 0x0097a7, 0x69 }, { 0x00acc1, 0x68 }, { 0x00b0ff, 0x60 }, { 0x00b8d4, 0x6f }, { 0x00bcd4, 0x67 }, { 0x00bfa5, 0x7d }, { 0x00c853, 0x8b },
     330             :         { 0x00e5ff, 0x6e }, { 0x00e676, 0x8a }, { 0x01579b, 0x5d }, { 0x0277bd, 0x5c }, { 0x0288d1, 0x5b }, { 0x039be5, 0x5a }, { 0x03a9f4, 0x59 }, { 0x0d47a1, 0x4f },
     331             :         { 0x1565c0, 0x4e }, { 0x18ffff, 0x6d }, { 0x1976d2, 0x4d }, { 0x1a237e, 0x41 }, { 0x1b5e20, 0x87 }, { 0x1de9b6, 0x7c }, { 0x1e88e5, 0x4c }, { 0x212121, 0xf3 },
     332             :         { 0x2196f3, 0x4b }, { 0x263238, 0xfd }, { 0x26a69a, 0x74 }, { 0x26c6da, 0x66 }, { 0x283593, 0x40 }, { 0x2962ff, 0x53 }, { 0x2979ff, 0x52 }, { 0x29b6f6, 0x58 },
     333             :         { 0x2e7d32, 0x86 }, { 0x303f9f, 0x3f }, { 0x304ffe, 0x45 }, { 0x311b92, 0x33 }, { 0x33691e, 0x95 }, { 0x37474f, 0xfc }, { 0x388e3c, 0x85 }, { 0x3949ab, 0x3e },
     334             :         { 0x3d5afe, 0x44 }, { 0x3e2723, 0xe9 }, { 0x3f51b5, 0x3d }, { 0x40c4ff, 0x5f }, { 0x424242, 0xf2 }, { 0x42a5f5, 0x4a }, { 0x43a047, 0x84 }, { 0x448aff, 0x51 },
     335             :         { 0x4527a0, 0x32 }, { 0x455a64, 0xfb }, { 0x4a148c, 0x25 }, { 0x4caf50, 0x83 }, { 0x4db6ac, 0x73 }, { 0x4dd0e1, 0x65 }, { 0x4e342e, 0xe8 }, { 0x4fc3f7, 0x57 },
     336             :         { 0x512da8, 0x31 }, { 0x536dfe, 0x43 }, { 0x546e7a, 0xfa }, { 0x558b2f, 0x94 }, { 0x5c6bc0, 0x3c }, { 0x5d4037, 0xe7 }, { 0x5e35b1, 0x30 }, { 0x607d8b, 0xf9 },
     337             :         { 0x616161, 0xf1 }, { 0x6200ea, 0x37 }, { 0x64b5f6, 0x49 }, { 0x64dd17, 0x99 }, { 0x64ffda, 0x7b }, { 0x651fff, 0x36 }, { 0x66bb6a, 0x82 }, { 0x673ab7, 0x2f },
     338             :         { 0x689f38, 0x93 }, { 0x69f0ae, 0x89 }, { 0x6a1b9a, 0x24 }, { 0x6d4c41, 0xe6 }, { 0x757575, 0xf0 }, { 0x76ff03, 0x98 }, { 0x78909c, 0xf8 }, { 0x795548, 0xe5 },
     339             :         { 0x7986cb, 0x3b }, { 0x7b1fa2, 0x23 }, { 0x7c4dff, 0x35 }, { 0x7cb342, 0x92 }, { 0x7e57c2, 0x2e }, { 0x80cbc4, 0x72 }, { 0x80d8ff, 0x5e }, { 0x80deea, 0x64 },
     340             :         { 0x81c784, 0x81 }, { 0x81d4fa, 0x56 }, { 0x827717, 0xa3 }, { 0x82b1ff, 0x50 }, { 0x84ffff, 0x6c }, { 0x880e4f, 0x17 }, { 0x8bc34a, 0x91 }, { 0x8c9eff, 0x42 },
     341             :         { 0x8d6e63, 0xe4 }, { 0x8e24aa, 0x22 }, { 0x90a4ae, 0xf7 }, { 0x90caf9, 0x48 }, { 0x9575cd, 0x2d }, { 0x9c27b0, 0x21 }, { 0x9ccc65, 0x90 }, { 0x9e9d24, 0xa2 },
     342             :         { 0x9e9e9e, 0xef }, { 0x9fa8da, 0x3a }, { 0xa1887f, 0xe3 }, { 0xa5d6a7, 0x80 }, { 0xa7ffeb, 0x7a }, { 0xaa00ff, 0x29 }, { 0xab47bc, 0x20 }, { 0xad1457, 0x16 },
     343             :         { 0xaed581, 0x8f }, { 0xaeea00, 0xa7 }, { 0xafb42b, 0xa1 }, { 0xb0bec5, 0xf6 }, { 0xb2dfdb, 0x71 }, { 0xb2ebf2, 0x63 }, { 0xb2ff59, 0x97 }, { 0xb388ff, 0x34 },
     344             :         { 0xb39ddb, 0x2c }, { 0xb3e5fc, 0x55 }, { 0xb71c1c, 0x09 }, { 0xb9f6ca, 0x88 }, { 0xba68c8, 0x1f }, { 0xbbdefb, 0x47 }, { 0xbcaaa4, 0xe2 }, { 0xbdbdbd, 0xee },
     345             :         { 0xbf360c, 0xdb }, { 0xc0ca33, 0xa0 }, { 0xc2185b, 0x15 }, { 0xc51162, 0x1b }, { 0xc5cae9, 0x39 }, { 0xc5e1a5, 0x8e }, { 0xc62828, 0x08 }, { 0xc6ff00, 0xa6 },
     346             :         { 0xc8e6c9, 0x7f }, { 0xccff90, 0x96 }, { 0xcddc39, 0x9f }, { 0xce93d8, 0x1e }, { 0xcfd8dc, 0xf5 }, { 0xd1c4e9, 0x2b }, { 0xd32f2f, 0x07 }, { 0xd4e157, 0x9e },
     347             :         { 0xd50000, 0x0d }, { 0xd500f9, 0x28 }, { 0xd7ccc8, 0xe1 }, { 0xd81b60, 0x14 }, { 0xd84315, 0xda }, { 0xdce775, 0x9d }, { 0xdcedc8, 0x8d }, { 0xdd2c00, 0xdf },
     348             :         { 0xe040fb, 0x27 }, { 0xe0e0e0, 0xed }, { 0xe0f2f1, 0x70 }, { 0xe0f7fa, 0x62 }, { 0xe1bee7, 0x1d }, { 0xe1f5fe, 0x54 }, { 0xe3f2fd, 0x46 }, { 0xe53935, 0x06 },
     349             :         { 0xe57373, 0x03 }, { 0xe64a19, 0xd9 }, { 0xe65100, 0xcd }, { 0xe6ee9c, 0x9c }, { 0xe8eaf6, 0x38 }, { 0xe8f5e9, 0x7e }, { 0xe91e63, 0x13 }, { 0xea80fc, 0x26 },
     350             :         { 0xec407a, 0x12 }, { 0xeceff1, 0xf4 }, { 0xede7f6, 0x2a }, { 0xeeeeee, 0xec }, { 0xeeff41, 0xa5 }, { 0xef5350, 0x04 }, { 0xef6c00, 0xcc }, { 0xef9a9a, 0x02 },
     351             :         { 0xefebe9, 0xe0 }, { 0xf06292, 0x11 }, { 0xf0f4c3, 0x9b }, { 0xf1f8e9, 0x8c }, { 0xf3e5f5, 0x1c }, { 0xf44336, 0x05 }, { 0xf4511e, 0xd8 }, { 0xf48fb1, 0x10 },
     352             :         { 0xf4ff81, 0xa4 }, { 0xf50057, 0x1a }, { 0xf57c00, 0xcb }, { 0xf57f17, 0xb1 }, { 0xf5f5f5, 0xeb }, { 0xf8bbd0, 0x0f }, { 0xf9a825, 0xb0 }, { 0xf9fbe7, 0x9a },
     353             :         { 0xfafafa, 0xea }, { 0xfb8c00, 0xca }, { 0xfbc02d, 0xaf }, { 0xfbe9e7, 0xd2 }, { 0xfce4ec, 0x0e }, { 0xfdd835, 0xae }, { 0xff1744, 0x0c }, { 0xff3d00, 0xde },
     354             :         { 0xff4081, 0x19 }, { 0xff5252, 0x0b }, { 0xff5722, 0xd7 }, { 0xff6d00, 0xd1 }, { 0xff6e40, 0xdd }, { 0xff6f00, 0xbf }, { 0xff7043, 0xd6 }, { 0xff80ab, 0x18 },
     355             :         { 0xff8a65, 0xd5 }, { 0xff8a80, 0x0a }, { 0xff8f00, 0xbe }, { 0xff9100, 0xd0 }, { 0xff9800, 0xc9 }, { 0xff9e80, 0xdc }, { 0xffa000, 0xbd }, { 0xffa726, 0xc8 },
     356             :         { 0xffab00, 0xc3 }, { 0xffab40, 0xcf }, { 0xffab91, 0xd4 }, { 0xffb300, 0xbc }, { 0xffb74d, 0xc7 }, { 0xffc107, 0xbb }, { 0xffc400, 0xc2 }, { 0xffca28, 0xba },
     357             :         { 0xffcc80, 0xc6 }, { 0xffccbc, 0xd3 }, { 0xffcdd2, 0x01 }, { 0xffd180, 0xce }, { 0xffd54f, 0xb9 }, { 0xffd600, 0xb5 }, { 0xffd740, 0xc1 }, { 0xffe082, 0xb8 },
     358             :         { 0xffe0b2, 0xc5 }, { 0xffe57f, 0xc0 }, { 0xffea00, 0xb4 }, { 0xffeb3b, 0xad }, { 0xffebee, 0x00 }, { 0xffecb3, 0xb7 }, { 0xffee58, 0xac }, { 0xfff176, 0xab },
     359             :         { 0xfff3e0, 0xc4 }, { 0xfff59d, 0xaa }, { 0xfff8e1, 0xb6 }, { 0xfff9c4, 0xa9 }, { 0xfffde7, 0xa8 }, { 0xffff00, 0xb3 }, { 0xffff8d, 0xb2 }, { 0xffffff, 0xfe },
     360             : };
     361             : 
     362             : static struct ColorIndexIndex {
     363             :         uint16_t index;
     364             :         uint8_t idx;
     365             : } indexIndex[256] = {
     366             :         { 0x000, 0x00 }, { 0x001, 0x01 }, { 0x002, 0x02 }, { 0x003, 0x03 }, { 0x004, 0x04 }, { 0x005, 0x05 }, { 0x006, 0x06 }, { 0x007, 0x07 },
     367             :         { 0x008, 0x08 }, { 0x009, 0x09 }, { 0x00a, 0x0a }, { 0x00b, 0x0b }, { 0x00c, 0x0c }, { 0x00d, 0x0d }, { 0x010, 0x0e }, { 0x011, 0x0f },
     368             :         { 0x012, 0x10 }, { 0x013, 0x11 }, { 0x014, 0x12 }, { 0x015, 0x13 }, { 0x016, 0x14 }, { 0x017, 0x15 }, { 0x018, 0x16 }, { 0x019, 0x17 },
     369             :         { 0x01a, 0x18 }, { 0x01b, 0x19 }, { 0x01c, 0x1a }, { 0x01d, 0x1b }, { 0x020, 0x1c }, { 0x021, 0x1d }, { 0x022, 0x1e }, { 0x023, 0x1f },
     370             :         { 0x024, 0x20 }, { 0x025, 0x21 }, { 0x026, 0x22 }, { 0x027, 0x23 }, { 0x028, 0x24 }, { 0x029, 0x25 }, { 0x02a, 0x26 }, { 0x02b, 0x27 },
     371             :         { 0x02c, 0x28 }, { 0x02d, 0x29 }, { 0x030, 0x2a }, { 0x031, 0x2b }, { 0x032, 0x2c }, { 0x033, 0x2d }, { 0x034, 0x2e }, { 0x035, 0x2f },
     372             :         { 0x036, 0x30 }, { 0x037, 0x31 }, { 0x038, 0x32 }, { 0x039, 0x33 }, { 0x03a, 0x34 }, { 0x03b, 0x35 }, { 0x03c, 0x36 }, { 0x03d, 0x37 },
     373             :         { 0x040, 0x38 }, { 0x041, 0x39 }, { 0x042, 0x3a }, { 0x043, 0x3b }, { 0x044, 0x3c }, { 0x045, 0x3d }, { 0x046, 0x3e }, { 0x047, 0x3f },
     374             :         { 0x048, 0x40 }, { 0x049, 0x41 }, { 0x04a, 0x42 }, { 0x04b, 0x43 }, { 0x04c, 0x44 }, { 0x04d, 0x45 }, { 0x050, 0x46 }, { 0x051, 0x47 },
     375             :         { 0x052, 0x48 }, { 0x053, 0x49 }, { 0x054, 0x4a }, { 0x055, 0x4b }, { 0x056, 0x4c }, { 0x057, 0x4d }, { 0x058, 0x4e }, { 0x059, 0x4f },
     376             :         { 0x05a, 0x50 }, { 0x05b, 0x51 }, { 0x05c, 0x52 }, { 0x05d, 0x53 }, { 0x060, 0x54 }, { 0x061, 0x55 }, { 0x062, 0x56 }, { 0x063, 0x57 },
     377             :         { 0x064, 0x58 }, { 0x065, 0x59 }, { 0x066, 0x5a }, { 0x067, 0x5b }, { 0x068, 0x5c }, { 0x069, 0x5d }, { 0x06a, 0x5e }, { 0x06b, 0x5f },
     378             :         { 0x06c, 0x60 }, { 0x06d, 0x61 }, { 0x070, 0x62 }, { 0x071, 0x63 }, { 0x072, 0x64 }, { 0x073, 0x65 }, { 0x074, 0x66 }, { 0x075, 0x67 },
     379             :         { 0x076, 0x68 }, { 0x077, 0x69 }, { 0x078, 0x6a }, { 0x079, 0x6b }, { 0x07a, 0x6c }, { 0x07b, 0x6d }, { 0x07c, 0x6e }, { 0x07d, 0x6f },
     380             :         { 0x080, 0x70 }, { 0x081, 0x71 }, { 0x082, 0x72 }, { 0x083, 0x73 }, { 0x084, 0x74 }, { 0x085, 0x75 }, { 0x086, 0x76 }, { 0x087, 0x77 },
     381             :         { 0x088, 0x78 }, { 0x089, 0x79 }, { 0x08a, 0x7a }, { 0x08b, 0x7b }, { 0x08c, 0x7c }, { 0x08d, 0x7d }, { 0x090, 0x7e }, { 0x091, 0x7f },
     382             :         { 0x092, 0x80 }, { 0x093, 0x81 }, { 0x094, 0x82 }, { 0x095, 0x83 }, { 0x096, 0x84 }, { 0x097, 0x85 }, { 0x098, 0x86 }, { 0x099, 0x87 },
     383             :         { 0x09a, 0x88 }, { 0x09b, 0x89 }, { 0x09c, 0x8a }, { 0x09d, 0x8b }, { 0x0a0, 0x8c }, { 0x0a1, 0x8d }, { 0x0a2, 0x8e }, { 0x0a3, 0x8f },
     384             :         { 0x0a4, 0x90 }, { 0x0a5, 0x91 }, { 0x0a6, 0x92 }, { 0x0a7, 0x93 }, { 0x0a8, 0x94 }, { 0x0a9, 0x95 }, { 0x0aa, 0x96 }, { 0x0ab, 0x97 },
     385             :         { 0x0ac, 0x98 }, { 0x0ad, 0x99 }, { 0x0b0, 0x9a }, { 0x0b1, 0x9b }, { 0x0b2, 0x9c }, { 0x0b3, 0x9d }, { 0x0b4, 0x9e }, { 0x0b5, 0x9f },
     386             :         { 0x0b6, 0xa0 }, { 0x0b7, 0xa1 }, { 0x0b8, 0xa2 }, { 0x0b9, 0xa3 }, { 0x0ba, 0xa4 }, { 0x0bb, 0xa5 }, { 0x0bc, 0xa6 }, { 0x0bd, 0xa7 },
     387             :         { 0x0c0, 0xa8 }, { 0x0c1, 0xa9 }, { 0x0c2, 0xaa }, { 0x0c3, 0xab }, { 0x0c4, 0xac }, { 0x0c5, 0xad }, { 0x0c6, 0xae }, { 0x0c7, 0xaf },
     388             :         { 0x0c8, 0xb0 }, { 0x0c9, 0xb1 }, { 0x0ca, 0xb2 }, { 0x0cb, 0xb3 }, { 0x0cc, 0xb4 }, { 0x0cd, 0xb5 }, { 0x0d0, 0xb6 }, { 0x0d1, 0xb7 },
     389             :         { 0x0d2, 0xb8 }, { 0x0d3, 0xb9 }, { 0x0d4, 0xba }, { 0x0d5, 0xbb }, { 0x0d6, 0xbc }, { 0x0d7, 0xbd }, { 0x0d8, 0xbe }, { 0x0d9, 0xbf },
     390             :         { 0x0da, 0xc0 }, { 0x0db, 0xc1 }, { 0x0dc, 0xc2 }, { 0x0dd, 0xc3 }, { 0x0e0, 0xc4 }, { 0x0e1, 0xc5 }, { 0x0e2, 0xc6 }, { 0x0e3, 0xc7 },
     391             :         { 0x0e4, 0xc8 }, { 0x0e5, 0xc9 }, { 0x0e6, 0xca }, { 0x0e7, 0xcb }, { 0x0e8, 0xcc }, { 0x0e9, 0xcd }, { 0x0ea, 0xce }, { 0x0eb, 0xcf },
     392             :         { 0x0ec, 0xd0 }, { 0x0ed, 0xd1 }, { 0x0f0, 0xd2 }, { 0x0f1, 0xd3 }, { 0x0f2, 0xd4 }, { 0x0f3, 0xd5 }, { 0x0f4, 0xd6 }, { 0x0f5, 0xd7 },
     393             :         { 0x0f6, 0xd8 }, { 0x0f7, 0xd9 }, { 0x0f8, 0xda }, { 0x0f9, 0xdb }, { 0x0fa, 0xdc }, { 0x0fb, 0xdd }, { 0x0fc, 0xde }, { 0x0fd, 0xdf },
     394             :         { 0x100, 0xe0 }, { 0x101, 0xe1 }, { 0x102, 0xe2 }, { 0x103, 0xe3 }, { 0x104, 0xe4 }, { 0x105, 0xe5 }, { 0x106, 0xe6 }, { 0x107, 0xe7 },
     395             :         { 0x108, 0xe8 }, { 0x109, 0xe9 }, { 0x110, 0xea }, { 0x111, 0xeb }, { 0x112, 0xec }, { 0x113, 0xed }, { 0x114, 0xee }, { 0x115, 0xef },
     396             :         { 0x116, 0xf0 }, { 0x117, 0xf1 }, { 0x118, 0xf2 }, { 0x119, 0xf3 }, { 0x120, 0xf4 }, { 0x121, 0xf5 }, { 0x122, 0xf6 }, { 0x123, 0xf7 },
     397             :         { 0x124, 0xf8 }, { 0x125, 0xf9 }, { 0x126, 0xfa }, { 0x127, 0xfb }, { 0x128, 0xfc }, { 0x129, 0xfd }, { 0x130, 0xfe }, { 0x131, 0xff },
     398             : };
     399             : 
     400             : static struct ColorIndexName {
     401             :         uint32_t hash;
     402             :         uint8_t idx;
     403             : } nameIndex[256] = {
     404             :         { 0x00deac8f, 0xe6 }, { 0x01479189, 0x7a }, { 0x01822ea0, 0xa0 }, { 0x028ea97f, 0x0b }, { 0x02d1e3c2, 0xe3 }, { 0x049de544, 0x02 }, { 0x054596d0, 0x1c }, { 0x0556a2bf, 0x7d },
     405             :         { 0x06e0f4f8, 0xe9 }, { 0x078476a9, 0xa1 }, { 0x09b7420b, 0xdc }, { 0x0a80b3f2, 0x43 }, { 0x0aa02d4d, 0x03 }, { 0x0b93875f, 0x9b }, { 0x0ce33ce1, 0xe8 }, { 0x0d86be92, 0x9e },
     406             :         { 0x0e77e7af, 0xc1 }, { 0x1389069b, 0x9f }, { 0x1536e672, 0xfa }, { 0x15a4e07e, 0xa2 }, { 0x15bbd27d, 0xdf }, { 0x168543e4, 0x44 }, { 0x18758672, 0x82 }, { 0x19282970, 0x15 },
     407             :         { 0x1b392e7b, 0xfb }, { 0x1b4f6967, 0x8c }, { 0x1ba72867, 0xa3 }, { 0x1c8c6940, 0x21 }, { 0x1ccc6851, 0x53 }, { 0x1d373a26, 0x0f }, { 0x1e77ce7b, 0x83 }, { 0x1e7bbc84, 0x88 },
     408             :         { 0x206a9ed6, 0xd3 }, { 0x209b7a76, 0x1f }, { 0x228eb149, 0x20 }, { 0x22ceb05a, 0x52 }, { 0x2303ea21, 0xb5 }, { 0x247a1664, 0x80 }, { 0x24aa8b2c, 0x25 }, { 0x257885fc, 0x70 },
     409             :         { 0x266bf079, 0xbd }, { 0x269dc27f, 0x1e }, { 0x2712fad7, 0xb2 }, { 0x273dbe6d, 0xf5 }, { 0x2a7c5e6d, 0x81 }, { 0x2aacd315, 0x24 }, { 0x2ad633f2, 0xa7 }, { 0x2c6e3862, 0xba },
     410             :         { 0x2d4adace, 0x17 }, { 0x2f45a883, 0x56 }, { 0x3270806b, 0xbb }, { 0x32c07b50, 0xc9 }, { 0x34664104, 0xd5 }, { 0x3547f08c, 0x59 }, { 0x36cf8c06, 0xc7 }, { 0x36dac3e4, 0xa4 },
     411             :         { 0x3735245d, 0x10 }, { 0x3872c854, 0xb8 }, { 0x38c2c359, 0xc8 }, { 0x3a68890d, 0xd4 }, { 0x3a8ea237, 0xbf }, { 0x3b4a38f5, 0x58 }, { 0x3c8c68e3, 0x32 }, { 0x3cd1d40f, 0xc6 },
     412             :         { 0x3ec50b42, 0xcb }, { 0x3f00b37b, 0x18 }, { 0x401e7178, 0xfe }, { 0x40dd46d6, 0x3f }, { 0x40e0e525, 0xcc }, { 0x455a4d25, 0xce }, { 0x4635a5e7, 0xea }, { 0x4676b272, 0x2b },
     413             :         { 0x474d8478, 0xd0 }, { 0x4a92a6a3, 0x6e }, { 0x4b05436d, 0x1b }, { 0x4b45fd26, 0x0e }, { 0x4b5c952e, 0xcf }, { 0x4e44e82c, 0x99 }, { 0x5194b803, 0x29 }, { 0x527b4264, 0x31 },
     414             :         { 0x54d8e904, 0x3d }, { 0x568a531a, 0x33 }, { 0x56e28340, 0x94 }, { 0x587d8a6d, 0x30 }, { 0x59fab2d2, 0xb1 }, { 0x5adb310d, 0x3c }, { 0x5b962f01, 0x5e }, { 0x5ce4cb49, 0x95 },
     415             :         { 0x5d994875, 0x26 }, { 0x5e09c388, 0xab }, { 0x5e69ab72, 0x36 }, { 0x5e8e7be2, 0xff }, { 0x5f00a52c, 0x90 }, { 0x5f53c0c0, 0xf2 }, { 0x5fa54037, 0x61 }, { 0x5ffcfadb, 0xb0 },
     416             :         { 0x604bc007, 0x98 }, { 0x60b10220, 0x71 }, { 0x60eb4716, 0xd2 }, { 0x60fc1ee2, 0x4f }, { 0x6198770a, 0x5f }, { 0x6218d4be, 0xad }, { 0x640c0bf1, 0xaa }, { 0x6502ed15, 0x91 },
     417             :         { 0x650b2f98, 0x49 }, { 0x655608c9, 0xf3 }, { 0x669ef003, 0xf4 }, { 0x66fe66eb, 0x4e }, { 0x6771e2ac, 0xee }, { 0x681b1ca7, 0xac }, { 0x6a0e53fa, 0xa9 }, { 0x6a6e3b64, 0x35 },
     418             :         { 0x6ac25adf, 0x76 }, { 0x6b05351e, 0x92 }, { 0x6b0d7781, 0x48 }, { 0x6c93fbe0, 0x06 }, { 0x6cb59212, 0x73 }, { 0x6d742a95, 0xef }, { 0x6f1c88b7, 0x4a }, { 0x70c4a2c8, 0x79 },
     419             :         { 0x71077d07, 0x93 }, { 0x710fbf8a, 0x47 }, { 0x729643e9, 0x07 }, { 0x72b7da1b, 0x72 }, { 0x7376729e, 0xf0 }, { 0x76a5549f, 0x01 }, { 0x76c6eb31, 0x78 }, { 0x77afa090, 0xdd },
     420             :         { 0x78988bd2, 0x04 }, { 0x79194eec, 0xe0 }, { 0x7978ba87, 0xf1 }, { 0x79873b3c, 0x6a }, { 0x7aa9e319, 0xb6 }, { 0x7bbeb146, 0xde }, { 0x7e9ad3db, 0x05 }, { 0x7f6f7c22, 0x2a },
     421             :         { 0x80b6adbe, 0x08 }, { 0x8209d369, 0x7e }, { 0x8371844b, 0x69 }, { 0x847da209, 0x42 }, { 0x8482aa32, 0x0d }, { 0x86b8f5a7, 0x09 }, { 0x874aa372, 0x7b }, { 0x888cb33f, 0x45 },
     422             :         { 0x88d4f54b, 0xe2 }, { 0x89318c80, 0xf8 }, { 0x8a69a079, 0xc2 }, { 0x8c702c80, 0x84 }, { 0x8c741b29, 0x8a }, { 0x8d409db6, 0xf6 }, { 0x8ed3d7ac, 0x51 }, { 0x8ed73db4, 0xe5 },
     423             :         { 0x8f33d489, 0xf9 }, { 0x8f7614bd, 0x63 }, { 0x906be862, 0xc3 }, { 0x90832bdf, 0x89 }, { 0x90873a24, 0x0a }, { 0x914fae6c, 0xfc }, { 0x923cbb49, 0x00 }, { 0x92727489, 0x85 },
     424             :         { 0x92766312, 0x8b }, { 0x9342e5bf, 0xf7 }, { 0x934f3364, 0x7c }, { 0x94d985bd, 0xe4 }, { 0x950b597c, 0xb3 }, { 0x968185bf, 0x7f }, { 0x9751f655, 0xfd }, { 0x998c1804, 0x9c },
     425             :         { 0x9c5c57a0, 0xd9 }, { 0x9c707854, 0xc0 }, { 0x9f2b3af9, 0x14 }, { 0x9f8e600d, 0x9d }, { 0xa068def0, 0xbc }, { 0xa092de5e, 0x86 }, { 0xa0daaf87, 0x50 }, { 0xa25e9fa9, 0xd8 },
     426             :         { 0xa4d32209, 0xa6 }, { 0xa52d82e2, 0x13 }, { 0xa6952647, 0x87 }, { 0xa860e792, 0xd7 }, { 0xa891c332, 0x23 }, { 0xa8e2333f, 0xa5 }, { 0xa906fbaa, 0xb4 }, { 0xaa7a37af, 0xb7 },
     427             :         { 0xab2fcaeb, 0x12 }, { 0xacf91180, 0x19 }, { 0xad2a98a0, 0x5d }, { 0xae632f9b, 0xd6 }, { 0xae940b3b, 0x22 }, { 0xb07f097e, 0xdb }, { 0xb0f07589, 0x9a }, { 0xb10822b6, 0x1a },
     428             :         { 0xb13212d4, 0x11 }, { 0xb32ce0a9, 0x5c }, { 0xb34decb7, 0x16 }, { 0xb48b904e, 0xbe }, { 0xb4965324, 0x1d }, { 0xb6815167, 0xda }, { 0xb954f3b3, 0xd1 }, { 0xba715880, 0x2d },
     429             :         { 0xbaddd3bc, 0xcd }, { 0xbcceffa0, 0x39 }, { 0xbd3e3948, 0x55 }, { 0xbe75d9dd, 0xb9 }, { 0xbe8069b6, 0x2f }, { 0xc073a089, 0x2c }, { 0xc14d4a7e, 0x5b }, { 0xc482b1bf, 0x2e },
     430             :         { 0xc4c81ccb, 0xca }, { 0xc6e0585f, 0x3e }, { 0xc74f9267, 0x5a }, { 0xc8d38f92, 0x3b }, { 0xc942c9ba, 0x57 }, { 0xcaca6534, 0xc5 }, { 0xcce2a048, 0x41 }, { 0xcd9d9e5c, 0x60 },
     431             :         { 0xced5d79b, 0x3a }, { 0xd2e4e8b1, 0x40 }, { 0xd6137acc, 0xaf }, { 0xd6980015, 0x6d }, { 0xd8669989, 0x37 }, { 0xd88b3768, 0x6f }, { 0xd8fd93a3, 0x8f }, { 0xdc15c335, 0xae },
     432             :         { 0xdc3d78d1, 0x97 }, { 0xdc75aabf, 0x34 }, { 0xdc9a481e, 0x6c }, { 0xdcf7027c, 0x38 }, { 0xdd14e6dc, 0x4d }, { 0xdf8d48c8, 0x28 }, { 0xe16ed123, 0xed }, { 0xe23fc0da, 0x96 },
     433             :         { 0xe3172ec5, 0x4c }, { 0xe39c59fe, 0x27 }, { 0xe4bf4956, 0x77 }, { 0xe91976ce, 0x4b }, { 0xe9d03320, 0xc4 }, { 0xea0669fa, 0xa8 }, { 0xecdfdf13, 0x62 }, { 0xecf935d1, 0x8d },
     434             :         { 0xf169e2d0, 0x66 }, { 0xf2fb7dda, 0x8e }, { 0xf56a7351, 0xeb }, { 0xf578f386, 0x64 }, { 0xf6cd53d0, 0xe1 }, { 0xf76c2ad9, 0x67 }, { 0xf8baeb84, 0x75 }, { 0xfadc6486, 0xe7 },
     435             :         { 0xfb6cbb5a, 0xec }, { 0xfb7b3b8f, 0x65 }, { 0xfd10b1d4, 0x54 }, { 0xfd6e72c2, 0x68 }, { 0xfe7f9849, 0x0c }, { 0xfebd338d, 0x74 }, { 0xfece83ca, 0x46 }, { 0xff8a4ca5, 0x6b },
     436             : };
     437             : 
     438             : namespace fnv1 {
     439             : // see https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function#FNV-1_hash
     440             : // parameters from http://www.boost.org/doc/libs/1_38_0/libs/unordered/examples/fnv1.hpp
     441             : 
     442        1425 : constexpr uint32_t _fnv_offset_basis() { return uint32_t(2166136261llu); }
     443       12625 : constexpr uint32_t _fnv_prime() { return uint32_t(16777619llu); }
     444             : 
     445             : constexpr uint32_t _fnv1(const uint8_t* ptr, size_t len) {
     446             :         uint32_t hash = _fnv_offset_basis();
     447             :         for (size_t i = 0; i < len; i++) {
     448             :              hash *= _fnv_prime();
     449             :              hash ^= ptr[i];
     450             :         }
     451             :         return hash;
     452             : }
     453             : 
     454        1425 : constexpr uint32_t _fnv1Signed(const char* ptr, size_t len) {
     455        1425 :         uint32_t hash = _fnv_offset_basis();
     456       14050 :         for (size_t i = 0; i < len; i++) {
     457       12625 :              hash *= _fnv_prime();
     458             :              if constexpr (std::numeric_limits<char>::is_signed) {
     459       12625 :                      if (ptr[i] >= 0) {
     460       12625 :                              hash ^= ptr[i];
     461             :                      } else {
     462           0 :                          hash ^= -ptr[i] + 127;
     463             :                      }
     464             :              } else {
     465             :                      hash ^= ptr[i];
     466             :              }
     467             :         }
     468        1425 :         return hash;
     469             : }
     470             : 
     471        1425 : constexpr uint32_t hash32(const char* str, size_t len) {
     472        1425 :     return _fnv1Signed(str, len);
     473             : }
     474             : 
     475             : }
     476             : 
     477        1425 : bool getColor(const StringView &str, uint32_t &color) {
     478        1425 :         auto h = fnv1::hash32(str.data(), str.size());
     479             : 
     480        1425 :         auto it = std::lower_bound(&nameIndex[0], (&nameIndex[0]) + 256, h, [] (const ColorIndexName &l, const uint32_t &r) -> bool {
     481       11400 :                 return l.hash < r;
     482             :         });
     483             : 
     484        1425 :         if (it != (&nameIndex[0]) + 256) {
     485        1425 :                 uint8_t idx = it->idx;
     486        1425 :                 auto &d = data[idx];
     487        1425 :                 if (d.hash == h) {
     488         950 :                         color = d.value;
     489         950 :                         return true;
     490             :                 }
     491             :         }
     492             : 
     493         475 :         return false;
     494             : }
     495             : 
     496        1425 : bool getColor(const StringView &str, Color3B &color) {
     497        1425 :         uint32_t value = 0;
     498        1425 :         if (getColor(str, value)) {
     499         950 :                 color.r = (value >> 16) & 0xFF;
     500         950 :                 color.g = (value >> 8) & 0xFF;
     501         950 :                 color.b = value  & 0xFF;
     502         950 :                 return true;
     503             :         }
     504         475 :         return false;
     505             : }
     506             : 
     507         350 : StringView getName(uint32_t value) {
     508         350 :         auto it = std::lower_bound(&valueIndex[0], (&valueIndex[0]) + 256, value, [] (const ColorIndexValue &l, const uint32_t &r) -> bool {
     509        2825 :                 return l.value < r;
     510             :         });
     511             : 
     512         350 :         if (it != (&valueIndex[0]) + 256) {
     513         350 :                 uint8_t idx = it->idx;
     514         350 :                 auto &d = data[idx];
     515         350 :                 if (d.value == value) {
     516         225 :                         return StringView(d.str);
     517             :                 }
     518             :         }
     519             : 
     520         125 :         return StringView();
     521             : }
     522             : 
     523         100 : StringView getName(const Color3B &color) {
     524         100 :         return getName((uint32_t)( ((color.r << 16) & 0xFF0000) | ((color.g << 8) & 0xFF00) | (color.b & 0xFF) ));
     525             : }
     526             : 
     527        1220 : Color getByIndex(uint16_t idx) {
     528        1220 :         auto it = std::lower_bound(&indexIndex[0], (&indexIndex[0]) + 256, idx, [] (const ColorIndexIndex &l, const uint16_t &r) -> bool {
     529        9760 :                 return l.index < r;
     530             :         });
     531             : 
     532        1220 :         if (it != (&indexIndex[0]) + 256) {
     533        1220 :                 auto &d = data[it->idx];
     534        1220 :                 if (d.index == idx) {
     535        1220 :                         return Color(d.value, d.index);
     536             :                 }
     537             :         }
     538             : 
     539           0 :         return Color();
     540             : }
     541             : 
     542         650 : uint16_t getColorIndex(uint32_t value) {
     543         650 :         auto it = std::lower_bound(&valueIndex[0], (&valueIndex[0]) + 256, value, [] (const ColorIndexValue &l, const uint32_t &r) -> bool {
     544        5200 :                 return l.value < r;
     545             :         });
     546             : 
     547         650 :         if (it != (&valueIndex[0]) + 256) {
     548         650 :                 uint8_t idx = it->idx;
     549         650 :                 auto &d = data[idx];
     550         650 :                 if (d.value == value) {
     551          75 :                         return d.index;
     552             :                 }
     553             :         }
     554             : 
     555         575 :         return maxOf<uint16_t>();
     556             : }
     557             : 
     558             : }
     559             : 
     560             : 
     561          75 : static void setHslColor(Color3B &color, float h, float sl, float l) {
     562             :         float v;
     563             : 
     564          75 :         h = h / 360.0f;
     565          75 :         sl = sl / 100.0f;
     566          75 :         l = l / 100.0f;
     567             : 
     568             :         float r,g,b;
     569          75 :         r = l;   // default to gray
     570          75 :         g = l;
     571          75 :         b = l;
     572             : 
     573          75 :         v = (l <= 0.5) ? (l * (1.0 + sl)) : (l + sl - l * sl);
     574             : 
     575          75 :         if (v > 0) {
     576             :                 float m;
     577             :                 float sv;
     578             :                 int sextant;
     579             :                 float fract, vsf, mid1, mid2;
     580             : 
     581          75 :                 m = l + l - v;
     582          75 :                 sv = (v - m ) / v;
     583          75 :                 h *= 6.0;
     584          75 :                 sextant = (int)h;
     585          75 :                 fract = h - sextant;
     586          75 :                 vsf = v * sv * fract;
     587          75 :                 mid1 = m + vsf;
     588          75 :                 mid2 = v - vsf;
     589             : 
     590          75 :                 switch (sextant) {
     591           0 :                 case 0: r = v; g = mid1; b = m; break;
     592           0 :                 case 1: r = mid2; g = v; b = m; break;
     593          50 :                 case 2: r = m; g = v; b = mid1; break;
     594           0 :                 case 3: r = m; g = mid2; b = v; break;
     595           0 :                 case 4: r = mid1; g = m; b = v; break;
     596          25 :                 case 5: r = v; g = m; b = mid2; break;
     597             :                 }
     598             :         }
     599             : 
     600          75 :         color.r = (uint8_t)(r * 255.0f);
     601          75 :         color.g = (uint8_t)(g * 255.0f);
     602          75 :         color.b = (uint8_t)(b * 255.0f);
     603          75 : }
     604             : 
     605         150 : static bool readColorDigits(const StringView &origStr, float *b, int num, bool isRgb) {
     606         150 :         StringView str(origStr);
     607         150 :         str.skipChars<StringView::CharGroup<CharGroupId::WhiteSpace>>();
     608         150 :         if (!str.is('(')) {
     609           0 :                 return false;
     610             :         }
     611         150 :         ++ str;
     612             : 
     613         500 :         for (int i = 0; i < num; i++) {
     614         500 :                 if (!str.readFloat().grab(b[i])) {
     615           0 :                         return false;
     616             :                 }
     617             : 
     618         500 :                 if (b[i] < 0.0f) { b[i] = 0.0f; } // error - less then 0
     619         500 :                 if (isRgb) {
     620         250 :                         if (b[i] > 255.0f) {
     621          25 :                                 b[i] = 255.0f; // for RGB absolute values 255 is max
     622             :                         }
     623         250 :                 } else if (!isRgb && (i != 3)) {
     624         225 :                         if (i == 0 && b[i] > 359.0f) {
     625          25 :                                 b[i] = 359.0f; // for HSL: H value max is 359
     626         200 :                         } else if (i != 0 && b[i] > 100.0f) {
     627          25 :                                 b[i] = 100.0f; // for HSL: S and L max is 100%
     628             :                         }
     629          25 :                 } else if (i == 3 && b[i] > 1.0f) {
     630          25 :                         b[i] = 1.0f; // for alpha - 1.0 is max
     631             :                 }
     632             : 
     633         500 :                 if (i == 3) {
     634          50 :                         b[i] = b[i] * 255.0f; // translate alpha to (0-255)
     635             :                 }
     636             : 
     637         500 :                 str.skipChars<StringView::CharGroup<CharGroupId::WhiteSpace>>();
     638             : 
     639         500 :                 if (str.empty()) {
     640           0 :                         return false;
     641             :                 }
     642             : 
     643         500 :                 if (str.is('%')) {
     644         175 :                         ++ str;
     645         175 :                         if (b[i] > 100.0f) {
     646           0 :                                 b[i] = 100.0f; // for percent values - max is 100
     647             :                         }
     648         175 :                         if (isRgb) {
     649          25 :                                 b[i] = 255.0f * b[i] / 100.0f; // translate RGB values to (0-255)
     650         150 :                         } else if ((!isRgb && i == 0) || i == 3) {
     651           0 :                                 return false; // for H in HSL and any alpha percent values is denied
     652             :                         }
     653         175 :                         str.skipChars<StringView::CharGroup<CharGroupId::WhiteSpace>>();
     654         325 :                 } else if (!isRgb && (i == 1 || i == 2) && !str.is('%')) {
     655           0 :                         return false; // for S and L in HSL only percent values allowed
     656             :                 }
     657             : 
     658         500 :                 if (str.empty()) {
     659           0 :                         return false;
     660             :                 }
     661             : 
     662         500 :                 str.skipChars<StringView::CharGroup<CharGroupId::WhiteSpace>, StringView::Chars<','>>();
     663             : 
     664         500 :                 if (str.is(')') && i == num - 1) {
     665         150 :                         return true;
     666             :                 }
     667             :         }
     668             : 
     669           0 :         return true;
     670             : }
     671             : 
     672          25 : static bool readRgbaColor(const StringView &origStr, Color3B &color, uint8_t &opacity) {
     673          25 :         float b[4] = { 0.0f };
     674          25 :         if (readColorDigits(origStr, b, 4, true)) {
     675          25 :                 color.r = (uint8_t)b[0];
     676          25 :                 color.g = (uint8_t)b[1];
     677          25 :                 color.b = (uint8_t)b[2];
     678          25 :                 opacity = (uint8_t)b[3];
     679          25 :                 return true;
     680             :         }
     681           0 :         return false;
     682             : }
     683             : 
     684          50 : static bool readRgbColor(const StringView &origStr, Color3B &color) {
     685          50 :         float b[3] = { 0.0f };
     686          50 :         if (readColorDigits(origStr, b, 3, true)) {
     687          50 :                 color.r = (uint8_t)b[0];
     688          50 :                 color.g = (uint8_t)b[1];
     689          50 :                 color.b = (uint8_t)b[2];
     690          50 :                 return true;
     691             :         }
     692           0 :         return false;
     693             : }
     694             : 
     695          25 : static bool readHslaColor(const StringView &origStr, Color3B &color, uint8_t &opacity) {
     696          25 :         float b[4] = { 0.0f };
     697          25 :         if (readColorDigits(origStr, b, 4, false)) {
     698          25 :                 setHslColor(color, b[0], b[1], b[2]);
     699          25 :                 opacity = (uint8_t)b[3];
     700          25 :                 return true;
     701             :         }
     702           0 :         return false;
     703             : }
     704             : 
     705          50 : static bool readHslColor(const StringView &origStr, Color3B &color) {
     706          50 :         float b[3] = { 0.0f };
     707          50 :         if (readColorDigits(origStr, b, 3, false)) {
     708          50 :                 setHslColor(color, b[0], b[1], b[2]);
     709          50 :                 return true;
     710             :         }
     711           0 :         return false;
     712             : }
     713             : 
     714         225 : static bool readHashColor(const StringView &origStr, Color3B &color) {
     715         225 :         StringView str(origStr);
     716         225 :         ++ str;
     717         225 :         if (str.size() == 6) {
     718         125 :                 color.r = base16::hexToChar(str[0], str[1]);
     719         125 :                 color.g = base16::hexToChar(str[2], str[3]);
     720         125 :                 color.b = base16::hexToChar(str[4], str[5]);
     721         100 :         } else if (str.size() == 3) {
     722         100 :                 color.r = base16::hexToChar(str[0], str[0]);
     723         100 :                 color.g = base16::hexToChar(str[1], str[1]);
     724         100 :                 color.b = base16::hexToChar(str[2], str[2]);
     725             :         } else {
     726           0 :                 return false;
     727             :         }
     728             : 
     729         225 :         return true;
     730             : }
     731             : 
     732          50 : static bool readHashColor(const StringView &origStr, Color4B &color) {
     733          50 :         StringView str(origStr);
     734          50 :         ++ str;
     735          50 :         if (str.size() == 8) {
     736          25 :                 color.r = base16::hexToChar(str[0], str[1]);
     737          25 :                 color.g = base16::hexToChar(str[2], str[3]);
     738          25 :                 color.b = base16::hexToChar(str[4], str[5]);
     739          25 :                 color.a = base16::hexToChar(str[4], str[5]);
     740          25 :         } else if (str.size() == 4) {
     741          25 :                 color.r = base16::hexToChar(str[0], str[0]);
     742          25 :                 color.g = base16::hexToChar(str[1], str[1]);
     743          25 :                 color.b = base16::hexToChar(str[2], str[2]);
     744          25 :                 color.a = base16::hexToChar(str[2], str[2]);
     745             :         } else {
     746           0 :                 return false;
     747             :         }
     748             : 
     749          50 :         return true;
     750             : }
     751             : 
     752        3125 : static bool readNamedColor(const StringView &origStr, Color3B &color) {
     753        3125 :         if (origStr.equals("white")) {
     754         125 :                 color = Color3B::WHITE;
     755        3000 :         } else if (origStr.equals("silver")) {
     756          50 :                 color = Color3B(192,192,192);
     757        2950 :         } else if (origStr.equals("gray") || origStr.equals("grey")) {
     758         100 :                 color = Color3B(128,128,128);
     759        2850 :         } else if (origStr.equals("black")) {
     760         575 :                 color = Color3B::BLACK;
     761        2275 :         } else if (origStr.equals("maroon")) {
     762         100 :                 color = Color3B(128,0,0);
     763        2175 :         } else if (origStr.equals("red")) {
     764         125 :                 color = Color3B(255,0,0);
     765        2050 :         } else if (origStr.equals("orange")) {
     766          50 :                 color = Color3B(255,165,0);
     767        2000 :         } else if (origStr.equals("yellow")) {
     768          50 :                 color = Color3B(255,255,0);
     769        1950 :         } else if (origStr.equals("olive")) {
     770          50 :                 color = Color3B(128,128,0);
     771        1900 :         } else if (origStr.equals("lime")) {
     772          50 :                 color = Color3B(0,255,0);
     773        1850 :         } else if (origStr.equals("green")) {
     774          75 :                 color = Color3B(0,128,0);
     775        1775 :         } else if (origStr.equals("aqua")) {
     776          50 :                 color = Color3B(0,255,255);
     777        1725 :         } else if (origStr.equals("blue")) {
     778         100 :                 color = Color3B(0,0,255);
     779        1625 :         } else if (origStr.equals("navy")) {
     780          50 :                 color = Color3B(0,0,128);
     781        1575 :         } else if (origStr.equals("teal")) {
     782          50 :                 color = Color3B(0,128,128);
     783        1525 :         } else if (origStr.equals("fuchsia")) {
     784          50 :                 color = Color3B(255,0,255);
     785        1475 :         } else if (origStr.equals("purple")) {
     786          50 :                 color = Color3B(128,0,128);
     787        1425 :         } else if (!table::getColor(origStr, color)) {
     788         475 :                 return false;
     789             :         }
     790        2650 :         return true;
     791             : }
     792             : 
     793        1150 : bool readColor(const StringView &str, Color4B &color4) {
     794        1150 :         Color3B color;
     795        1150 :         uint8_t opacity = 0;
     796        1150 :         if (str.starts_with("rgba")) {
     797          25 :                 if (readRgbaColor(StringView(str.data() + 4, str.size() - 4), color, opacity)) {
     798          25 :                         color4 = Color4B(color, opacity);
     799          25 :                         return true;
     800             :                 }
     801        1125 :         } else if (str.starts_with("hsla")) {
     802          25 :                 if (readHslaColor(StringView(str.data() + 4, str.size() - 4), color, opacity)) {
     803          25 :                         color4 = Color4B(color, opacity);
     804          25 :                         return true;
     805             :                 }
     806        1100 :         } else if (str.starts_with("rgb")) {
     807          25 :                 if (readRgbColor(StringView(str.data() + 3, str.size() - 3), color)) {
     808          25 :                         color4 = Color4B(color);
     809          25 :                         return true;
     810             :                 }
     811        1075 :         } else if (str.starts_with("hsl")) {
     812          25 :                 if (readHslColor(StringView(str.data() + 3, str.size() - 3), color)) {
     813          25 :                         color4 = Color4B(color);
     814          25 :                         return true;
     815             :                 }
     816        1050 :         } else if (str.is('#') && (str.size() == 4 || str.size() == 7)) {
     817          75 :                 if (readHashColor(str, color)) {
     818          75 :                         color4 = Color4B(color);
     819          75 :                         return true;
     820             :                 }
     821         975 :         } else if (str.is('#') && (str.size() == 5 || str.size() == 9)) {
     822          50 :                 if (readHashColor(str, color4)) {
     823          50 :                         return true;
     824             :                 }
     825             :         } else {
     826         925 :                 if (readNamedColor(str, color)) {
     827         925 :                         color4 = Color4B(color);
     828         925 :                         return true;
     829             :                 }
     830             :         }
     831           0 :         return false;
     832             : }
     833             : 
     834        2400 : bool readColor(const StringView &str, Color3B &color) {
     835        2400 :         if (str.starts_with("rgb")) {
     836          25 :                 if (readRgbColor(StringView(str.data() + 3, str.size() - 3), color)) {
     837          25 :                         return true;
     838             :                 }
     839        2375 :         } else if (str.starts_with("hsl")) {
     840          25 :                 if (readHslColor(StringView(str.data() + 3, str.size() - 3), color)) {
     841          25 :                         return true;
     842             :                 }
     843        2350 :         } else if (str.is('#')) {
     844         150 :                 if (readHashColor(str, color)) {
     845         150 :                         return true;
     846             :                 }
     847             :         } else {
     848        2200 :                 if (readNamedColor(str, color)) {
     849        1725 :                         return true;
     850             :                 }
     851             :         }
     852         475 :         return false;
     853             : }
     854             : 
     855             : 
     856             : MD_COLOR_SPEC_DEFINE(Red, 0, ffebee, ffcdd2, ef9a9a, e57373, ef5350, f44336, e53935, d32f2f, c62828, b71c1c, ff8a80, ff5252, ff1744, d50000 );
     857             : MD_COLOR_SPEC_DEFINE(Pink, 1, fce4ec, f8bbd0, f48fb1, f06292, ec407a, e91e63, d81b60, c2185b, ad1457, 880e4f, ff80ab, ff4081, f50057, c51162 );
     858             : MD_COLOR_SPEC_DEFINE(Purple, 2, f3e5f5, e1bee7, ce93d8, ba68c8, ab47bc, 9c27b0, 8e24aa, 7b1fa2, 6a1b9a, 4a148c, ea80fc, e040fb, d500f9, aa00ff );
     859             : MD_COLOR_SPEC_DEFINE(DeepPurple, 3, ede7f6, d1c4e9, b39ddb, 9575cd, 7e57c2, 673ab7, 5e35b1, 512da8, 4527a0, 311b92, b388ff, 7c4dff, 651fff, 6200ea );
     860             : MD_COLOR_SPEC_DEFINE(Indigo, 4, e8eaf6, c5cae9, 9fa8da, 7986cb, 5c6bc0, 3f51b5, 3949ab, 303f9f, 283593, 1a237e, 8c9eff, 536dfe, 3d5afe, 304ffe );
     861             : MD_COLOR_SPEC_DEFINE(Blue, 5, e3f2fd, bbdefb, 90caf9, 64b5f6, 42a5f5, 2196f3, 1e88e5, 1976d2, 1565c0, 0d47a1, 82b1ff, 448aff, 2979ff, 2962ff );
     862             : MD_COLOR_SPEC_DEFINE(LightBlue, 6, e1f5fe, b3e5fc, 81d4fa, 4fc3f7, 29b6f6, 03a9f4, 039be5, 0288d1, 0277bd, 01579b, 80d8ff, 40c4ff, 00b0ff, 0091ea );
     863             : MD_COLOR_SPEC_DEFINE(Cyan, 7, e0f7fa, b2ebf2, 80deea, 4dd0e1, 26c6da, 00bcd4, 00acc1, 0097a7, 00838f, 006064, 84ffff, 18ffff, 00e5ff, 00b8d4 );
     864             : MD_COLOR_SPEC_DEFINE(Teal, 8, e0f2f1, b2dfdb, 80cbc4, 4db6ac, 26a69a, 009688, 00897b, 00796b, 00695c, 004d40, a7ffeb, 64ffda, 1de9b6, 00bfa5 );
     865             : MD_COLOR_SPEC_DEFINE(Green, 9, e8f5e9, c8e6c9, a5d6a7, 81c784, 66bb6a, 4caf50, 43a047, 388e3c, 2e7d32, 1b5e20, b9f6ca, 69f0ae, 00e676, 00c853 );
     866             : MD_COLOR_SPEC_DEFINE(LightGreen, 10, f1f8e9, dcedc8, c5e1a5, aed581, 9ccc65, 8bc34a, 7cb342, 689f38, 558b2f, 33691e, ccff90, b2ff59, 76ff03, 64dd17 );
     867             : MD_COLOR_SPEC_DEFINE(Lime, 11, f9fbe7, f0f4c3, e6ee9c, dce775, d4e157, cddc39, c0ca33, afb42b, 9e9d24, 827717, f4ff81, eeff41, c6ff00, aeea00 );
     868             : MD_COLOR_SPEC_DEFINE(Yellow, 12, fffde7, fff9c4, fff59d, fff176, ffee58, ffeb3b, fdd835, fbc02d, f9a825, f57f17, ffff8d, ffff00, ffea00, ffd600 );
     869             : MD_COLOR_SPEC_DEFINE(Amber, 13, fff8e1, ffecb3, ffe082, ffd54f, ffca28, ffc107, ffb300, ffa000, ff8f00, ff6f00, ffe57f, ffd740, ffc400, ffab00 );
     870             : MD_COLOR_SPEC_DEFINE(Orange, 14, fff3e0, ffe0b2, ffcc80, ffb74d, ffa726, ff9800, fb8c00, f57c00, ef6c00, e65100, ffd180, ffab40, ff9100, ff6d00 );
     871             : MD_COLOR_SPEC_DEFINE(DeepOrange, 15, fbe9e7, ffccbc, ffab91, ff8a65, ff7043, ff5722, f4511e, e64a19, d84315, bf360c, ff9e80, ff6e40, ff3d00, dd2c00 );
     872             : MD_COLOR_SPEC_BASE_DEFINE(Brown, 16, efebe9, d7ccc8, bcaaa4, a1887f, 8d6e63, 795548, 6d4c41, 5d4037, 4e342e, 3e2723 );
     873             : MD_COLOR_SPEC_BASE_DEFINE(Grey, 17, fafafa, f5f5f5, eeeeee, e0e0e0, bdbdbd, 9e9e9e, 757575, 616161, 424242, 212121 );
     874             : MD_COLOR_SPEC_BASE_DEFINE(BlueGrey, 18, eceff1, cfd8dc, b0bec5, 90a4ae, 78909c, 607d8b, 546e7a, 455a64, 37474f, 263238 );
     875             : 
     876             : Color Color::White(0xFFFFFF, uint16_t(19 * 16 + 0));
     877             : Color Color::Black(0x000000, uint16_t(19 * 16 + 1));
     878             : 
     879             : struct _ColorHsl {
     880             :         float h;
     881             :         float s;
     882             :         float l;
     883             : };
     884             : 
     885         350 : static _ColorHsl rgb_to_hsl(uint32_t color) {
     886             :         _ColorHsl ret;
     887             :     float
     888         350 :         r = float((color >> (2 * 8)) & maxOf<uint8_t>()) / maxOf<uint8_t>(),
     889         350 :         g = float((color >> (1 * 8)) & maxOf<uint8_t>()) / maxOf<uint8_t>(),
     890         350 :         b = float((color >> (0 * 8)) & maxOf<uint8_t>()) / maxOf<uint8_t>();
     891             : 
     892             :     float
     893         350 :         maxv = std::max(std::max(r, g), b),
     894         350 :         minv = std::min(std::min(r, g), b),
     895         350 :                 d = maxv - minv;
     896             : 
     897         350 :     ret.l = (maxv + minv) / 2;
     898             : 
     899         350 :     if (maxv != minv) {
     900         350 :         ret.s = ret.l > 0.5f ? d / (2 - maxv - minv) : d / (maxv + minv);
     901         350 :         if (maxv == r) {
     902         175 :                 ret.h = (g - b) / d + (g < b ? 6 : 0);
     903         175 :         } else if (maxv == g) {
     904           0 :                 ret.h = (b - r) / d + 2;
     905         175 :         } else if (maxv == b) {
     906         175 :                 ret.h = (r - g) / d + 4;
     907             :         }
     908         350 :         ret.h /= 6;
     909             :     }
     910         350 :     return ret;
     911             : }
     912             : 
     913        1050 : static float hue_to_rgb(float v1, float v2, float vH) {
     914        1050 :         if (vH < 0)
     915         175 :                 vH += 1;
     916             : 
     917        1050 :         if (vH > 1)
     918           0 :                 vH -= 1;
     919             : 
     920        1050 :         if ((6 * vH) < 1)
     921         175 :                 return (v1 + (v2 - v1) * 6 * vH);
     922             : 
     923         875 :         if ((2 * vH) < 1)
     924         350 :                 return v2;
     925             : 
     926         525 :         if ((3 * vH) < 2)
     927         350 :                 return (v1 + (v2 - v1) * ((2.0f / 3) - vH) * 6);
     928             : 
     929         175 :         return v1;
     930             : }
     931             : 
     932         350 : static uint32_t hsl_to_rgb(const _ColorHsl &color, uint32_t source) {
     933         350 :         uint8_t r = 0;
     934         350 :         uint8_t g = 0;
     935         350 :         uint8_t b = 0;
     936             : 
     937         350 :         if (color.s == 0.0f) {
     938           0 :                 r = g = b = (uint8_t)(color.l * 255);
     939             :         } else {
     940             :                 float v1, v2;
     941         350 :                 const float hue = color.h;
     942             : 
     943         350 :                 v2 = (color.l < 0.5) ? (color.l * (1 + color.s)) : ((color.l + color.s) - (color.l * color.s));
     944         350 :                 v1 = 2 * color.l - v2;
     945             : 
     946         350 :                 r = (uint8_t)(255 * hue_to_rgb(v1, v2, hue + (1.0f / 3)));
     947         350 :                 g = (uint8_t)(255 * hue_to_rgb(v1, v2, hue));
     948         350 :                 b = (uint8_t)(255 * hue_to_rgb(v1, v2, hue - (1.0f / 3)));
     949             :         }
     950             : 
     951         350 :     return (uint32_t(r) << (2 * 8)) |
     952         350 :            (uint32_t(g) << (1 * 8)) |
     953         350 :            (uint32_t(b) << (0 * 8)) |
     954         350 :            (uint32_t((source >> (3 * 8)) & maxOf<uint8_t>()) << (3 * 8));
     955             : }
     956             : 
     957         350 : static float color_index_to_l(uint8_t id) {
     958         350 :         return 1.0f - (id + 1.5f) / 12.0f;
     959             : }
     960             : 
     961         200 : static uint8_t color_l_to_index(float l) {
     962         200 :         const float tmp = (1.0f - l) * 12.0f;
     963         200 :         if (tmp < 1.0f || tmp >= 11.0f) {
     964           0 :                 return maxOf<uint8_t>();
     965             :         }
     966         200 :         return uint8_t(roundf(tmp - 1.5f));
     967             : }
     968             : 
     969         100 : static uint32_t make_lighter(uint32_t color, uint8_t index) {
     970         100 :     _ColorHsl hsl = rgb_to_hsl(color);
     971             : 
     972         100 :     uint8_t id = color_l_to_index(hsl.l);
     973         100 :     if (id == maxOf<uint8_t>()) {
     974           0 :         return color;
     975             :     }
     976         100 :         if (id < index) {
     977           0 :                 id = 0;
     978             :         } else {
     979         100 :                 id = (id + 10 - index) % 10 + 1;
     980             :         }
     981         100 :         hsl.l = color_index_to_l(id);
     982             : 
     983         100 :     return hsl_to_rgb(hsl, color);
     984             : }
     985         100 : static uint32_t make_darker(uint32_t color, uint8_t index) {
     986         100 :     _ColorHsl hsl = rgb_to_hsl(color);
     987             : 
     988         100 :     uint8_t id = color_l_to_index(hsl.l);
     989         100 :     if (id == maxOf<uint8_t>()) {
     990           0 :         return color;
     991             :     }
     992         100 :         if (id + index > 9) {
     993           0 :                 id = 9;
     994             :         } else {
     995         100 :                 id = (id + 10 + index) % 10;
     996             :         }
     997         100 :         hsl.l = color_index_to_l(id);
     998             : 
     999         100 :     return hsl_to_rgb(hsl, color);
    1000             : }
    1001             : 
    1002         150 : static uint32_t make_specific(uint32_t color, uint8_t index) {
    1003         150 :     _ColorHsl hsl = rgb_to_hsl(color);
    1004             : 
    1005         150 :     if (index == 10) {
    1006           0 :         index = 1;
    1007         150 :     } else if (index == 11) {
    1008           0 :         index = 2;
    1009         150 :     } else if (index == 12) {
    1010           0 :         index = 4;
    1011         150 :     } else if (index == 13) {
    1012           0 :         index = 7;
    1013             :     } else {
    1014         150 :         index = 5;
    1015             :     }
    1016             : 
    1017         150 :         hsl.l = color_index_to_l(index);
    1018             : 
    1019         300 :     return hsl_to_rgb(hsl, color);
    1020             : }
    1021             : 
    1022        1220 : Color Color::getById(uint16_t index) {
    1023        1220 :         return table::getByIndex(index);
    1024             : }
    1025             : 
    1026         650 : uint16_t Color::getColorIndex(uint32_t value) {
    1027         650 :         return table::getColorIndex(value);
    1028             : }
    1029             : 
    1030        8195 : Color::Color(uint32_t value, int16_t index) {
    1031        8195 :         _value = value;
    1032        8195 :         _index = index;
    1033        8195 : }
    1034             : 
    1035         200 : Color Color::text() const {
    1036         200 :         float r = ((_value >> 16) & 0xFF) / 255.0f;
    1037         200 :         float g = ((_value >> 8) & 0xFF) / 255.0f;
    1038         200 :         float b = (_value & 0xFF) / 255.0f;
    1039             : 
    1040         200 :         float l = 0.2989f * r + 0.5870f * g + 0.1140f * b;
    1041             : 
    1042         200 :         if (l <= 0.55f) {
    1043         150 :                 return Color::White;
    1044             :         } else {
    1045          50 :                 return Color::Black;
    1046             :         }
    1047             : }
    1048             : 
    1049         550 : Color::Color(uint32_t value) : Color(value, getColorIndex(value)) { }
    1050             : 
    1051          75 : Color::Color(const Color3B &color)
    1052          75 : : Color((uint32_t)(((color.r << 16) & 0xFF0000) | ((color.g << 8) & 0xFF00) | (color.b & 0xFF))) {
    1053          75 :          _index = getColorIndex(_value);
    1054          75 : }
    1055             : 
    1056          25 : Color::Color(const Color4B &color)
    1057          25 : : Color((uint32_t)(((color.r << 16) & 0xFF0000) | ((color.g << 8) & 0xFF00) | (color.b & 0xFF))) {
    1058          25 :          _index = getColorIndex(_value);
    1059          25 : }
    1060             : 
    1061         870 : Color::Color(Tone tone, Level level) {
    1062         870 :         *this = getById((int16_t)tone * 16 | (int16_t)level);
    1063         870 : }
    1064             : 
    1065         100 : Color Color::previous() const {
    1066         100 :         return lighter(1);
    1067             : }
    1068         100 : Color Color::next() const {
    1069         100 :         return darker(1);
    1070             : }
    1071             : 
    1072         200 : Color Color::lighter(uint8_t index) const {
    1073         200 :         if (_index == maxOf<uint16_t>()) {
    1074         100 :                 return Color(make_lighter(_value, index));
    1075             :         }
    1076             : 
    1077         100 :         auto targetIndex = _index;
    1078         100 :         if (index > 0 && targetIndex == Color::Black._index) {
    1079           0 :                 targetIndex = Color::Grey_900._index;
    1080           0 :                 index --;
    1081             :         }
    1082             : 
    1083         100 :         uint16_t color = targetIndex & 0xFFF0;
    1084         100 :         uint16_t id = targetIndex & 0x0F;
    1085         100 :         if (id >= 0 && id <= 9) {
    1086          50 :         if (id < index) {
    1087          50 :             return getById(color | 0);
    1088             :         }
    1089           0 :                 id = (id + 10 - index) % 10;
    1090           0 :                 return getById(color | id);
    1091          50 :     } else if (id >= 10 && id <= 13) {
    1092          50 :         if (id - 10 < index) {
    1093           0 :             return getById(color | 10);
    1094             :         }
    1095          50 :                 id = (id - index);
    1096          50 :                 return getById(color | id);
    1097             :         } else {
    1098           0 :                 return Color(0);
    1099             :         }
    1100             : }
    1101         200 : Color Color::darker(uint8_t index) const {
    1102         200 :         if (_index == maxOf<uint16_t>()) {
    1103         100 :                 return Color(make_darker(_value, index));
    1104             :         }
    1105             : 
    1106         100 :         auto targetIndex = _index;
    1107         100 :         if (index > 0 && _index == Color::White._index) {
    1108           0 :                 targetIndex = Color::Grey_50._index;
    1109           0 :                 index --;
    1110             :         }
    1111             : 
    1112         100 :         uint16_t color = targetIndex &0xFFF0;
    1113         100 :         uint16_t id = targetIndex & 0x0F;
    1114         100 :         if (id >= 0 && id <= 9) {
    1115          50 :         if (id + index >= 9) {
    1116           0 :             return getById(color | 9);
    1117             :         }
    1118          50 :                 id = (id + index) % 10;
    1119          50 :                 return getById(color | id);
    1120          50 :     } else if (id >= 10 && id <= 13) {
    1121          50 :         if (id + index >= 13) {
    1122           0 :             return getById(color | 13);
    1123             :         }
    1124          50 :                 id = (id + index);
    1125          50 :                 return getById(color | id);
    1126             :         } else {
    1127           0 :                 return Color(0);
    1128             :         }
    1129             : }
    1130             : 
    1131         100 : Color Color::medium() const {
    1132         100 :         if (_index == maxOf<uint16_t>()) {
    1133          50 :                 return make_specific(_value, 5);
    1134             :         }
    1135          50 :         uint16_t color = _index &0xFFF0;
    1136          50 :         return getById(color | 5);
    1137             : }
    1138         200 : Color Color::specific(uint8_t index) const {
    1139         200 :         if (_index == maxOf<uint16_t>()) {
    1140         100 :                 return make_specific(_value, index);
    1141             :         }
    1142         100 :         uint16_t color = _index &0xFFF0;
    1143         100 :         return getById(color | index);
    1144             : }
    1145             : 
    1146         100 : Color Color::specific(Level tone) const {
    1147         100 :         return specific((uint8_t)tone);
    1148             : }
    1149             : 
    1150             : template <>
    1151          50 : auto Color::name<memory::PoolInterface>() const -> memory::PoolInterface::StringType {
    1152          50 :         auto ret = table::getName(_value);
    1153          50 :         if (ret.empty()) {
    1154          25 :                 ret = string::toString<memory::StandartInterface>(
    1155          50 :                                 "rgb(", uint32_t(_value >> 16 & 0xFF), ", ", uint32_t(_value >> 8 & 0xFF), ", ", uint32_t(_value & 0xFF), ")");
    1156             :         }
    1157         100 :         return ret.str<memory::PoolInterface>();
    1158             : }
    1159             : 
    1160             : template <>
    1161          50 : auto Color3B::name<memory::StandartInterface>() const -> memory::StandartInterface::StringType {
    1162          50 :         auto ret = table::getName(*this);
    1163          50 :         if (ret.empty()) {
    1164          25 :                 ret = string::toString<memory::StandartInterface>(
    1165          50 :                                 "rgb(", uint32_t(r >> 16 & 0xFF), ", ", uint32_t(g >> 8 & 0xFF), ", ", uint32_t(b & 0xFF), ")");
    1166             :         }
    1167         100 :         return ret.str<memory::StandartInterface>();
    1168             : }
    1169             : 
    1170             : template <>
    1171          50 : auto Color3B::name<memory::PoolInterface>() const -> memory::PoolInterface::StringType {
    1172          50 :         auto ret = table::getName(*this);
    1173          50 :         if (ret.empty()) {
    1174          25 :                 ret = string::toString<memory::StandartInterface>(
    1175          50 :                                 "rgb(", uint32_t(r >> 16 & 0xFF), ", ", uint32_t(g >> 8 & 0xFF), ", ", uint32_t(b & 0xFF), ")");
    1176             :         }
    1177         100 :         return ret.str<memory::PoolInterface>();
    1178             : }
    1179             : 
    1180             : template <>
    1181         200 : auto Color::name<memory::StandartInterface>() const -> memory::StandartInterface::StringType {
    1182         200 :         auto ret = table::getName(_value);
    1183         200 :         if (ret.empty()) {
    1184          50 :                 ret = string::toString<memory::StandartInterface>(
    1185         100 :                                 "rgb(", uint32_t(_value >> 16 & 0xFF), ", ", uint32_t(_value >> 8 & 0xFF), ", ", uint32_t(_value & 0xFF), ")");
    1186             :         }
    1187         400 :         return ret.str<memory::StandartInterface>();
    1188             : }
    1189             : 
    1190          75 : Color Color::getColorByName(const StringView &str, const Color &def) {
    1191          75 :         Color3B color;
    1192          75 :         if (readColor(str, color)) {
    1193          75 :                 return Color(color);
    1194             :         }
    1195           0 :         return def;
    1196             : }
    1197             : 
    1198          25 : Color Color::progress(const Color &a, const Color &b, float fp) {
    1199          25 :         uint8_t p = (uint8_t) (fp * 255.0f);
    1200          25 :         uint32_t val = (
    1201          25 :                         ( ( (a._value >> 16 & 0xFF) * (255 - p) + (b._value >> 16 & 0xFF) * p ) / 255 << 16 & 0xFF0000 ) |
    1202          25 :                         ( ( (a._value >> 8 & 0xFF) * (255 - p) + (b._value >> 8 & 0xFF) * p ) / 255 << 8 & 0xFF00) |
    1203          25 :                         ( ( (a._value & 0xFF) * (255 - p) + (b._value & 0xFF) * p ) / 255 & 0xFF)
    1204             :         );
    1205          25 :         return Color(val);
    1206             : }
    1207             : 
    1208          25 : Color3B Color3B::getColorByName(StringView str, const Color3B &def) {
    1209          25 :         Color3B color;
    1210          25 :         if (readColor(str, color)) {
    1211          25 :                 return color;
    1212             :         }
    1213           0 :         return def;
    1214             : }
    1215             : 
    1216          25 : Color4B Color4B::getColorByName(StringView str, const Color4B &def) {
    1217          25 :         Color4B color;
    1218          25 :         if (readColor(str, color)) {
    1219          25 :                 return color;
    1220             :         }
    1221           0 :         return def;
    1222             : }
    1223             : 
    1224          25 : Color3B::Color3B(const Color4B& color) : r(color.r), g(color.g), b(color.b) {}
    1225          50 : Color3B::Color3B(const Color4F& color) : r(color.r * 255.0f), g(color.g * 255.0f), b(color.b * 255.0f) {}
    1226             : 
    1227         360 : bool Color3B::operator==(const Color3B& right) const {
    1228         360 :     return (r == right.r && g == right.g && b == right.b);
    1229             : }
    1230             : 
    1231          50 : bool Color3B::operator==(const Color4B& right) const {
    1232          50 :     return (r == right.r && g == right.g && b == right.b && 255 == right.a);
    1233             : }
    1234             : 
    1235          50 : bool Color3B::operator==(const Color4F& right) const {
    1236          50 :     return (right.a == 1.0f && Color4F(*this) == right);
    1237             : }
    1238             : 
    1239          25 : bool Color3B::operator!=(const Color3B& right) const {
    1240          25 :     return !(*this == right);
    1241             : }
    1242             : 
    1243          25 : bool Color3B::operator!=(const Color4B& right) const {
    1244          25 :     return !(*this == right);
    1245             : }
    1246             : 
    1247          25 : bool Color3B::operator!=(const Color4F& right) const {
    1248          25 :     return !(*this == right);
    1249             : }
    1250             : 
    1251          25 : Color3B Color3B::progress(const Color3B &a, const Color3B &b, float fp) {
    1252          25 :         const uint8_t p = (uint8_t) (fp * 255.0f);
    1253          50 :         return Color3B(
    1254          25 :                 (a.r * (255 - p) + b.r * p) / 255,
    1255          25 :                 (a.g * (255 - p) + b.g * p) / 255,
    1256          25 :                 (a.b * (255 - p) + b.b * p) / 255
    1257          25 :         );
    1258             : }
    1259             : 
    1260        1050 : Color4B::Color4B(const Color3B& color) : r(color.r), g(color.g), b(color.b), a(255) { }
    1261          75 : Color4B::Color4B(const Color4F& color) : r(color.r * 255), g(color.g * 255), b(color.b * 255), a(color.a * 255) { }
    1262             : 
    1263        4122 : bool Color4B::operator==(const Color4B& right) const {
    1264        4122 :         return (r == right.r && g == right.g && b == right.b && a == right.a);
    1265             : }
    1266             : 
    1267          50 : bool Color4B::operator==(const Color3B& right) const {
    1268          50 :         return (r == right.r && g == right.g && b == right.b && a == 255);
    1269             : }
    1270             : 
    1271          50 : bool Color4B::operator==(const Color4F& right) const {
    1272          50 :         return (*this == Color4B(right));
    1273             : }
    1274             : 
    1275          25 : bool Color4B::operator!=(const Color4B& right) const {
    1276          25 :         return !(*this == right);
    1277             : }
    1278             : 
    1279          25 : bool Color4B::operator!=(const Color3B& right) const {
    1280          25 :         return !(*this == right);
    1281             : }
    1282             : 
    1283          25 : bool Color4B::operator!=(const Color4F& right) const {
    1284          25 :         return !(*this == right);
    1285             : }
    1286             : 
    1287          25 : Color4B Color4B::white(uint8_t opacity) {
    1288          25 :         return Color4B(255, 255, 255, opacity);
    1289             : }
    1290             : 
    1291          25 : Color4B Color4B::black(uint8_t opacity) {
    1292          25 :         return Color4B(0, 0, 0, opacity);
    1293             : }
    1294             : 
    1295          25 : Color4B Color4B::progress(const Color4B &a, const Color4B &b, float fp) {
    1296          25 :         const uint8_t p = (uint8_t) (fp * 255.0f);
    1297          50 :         return Color4B(
    1298          25 :                 (a.r * (255 - p) + b.r * p) / 255,
    1299          25 :                 (a.g * (255 - p) + b.g * p) / 255,
    1300          25 :                 (a.b * (255 - p) + b.b * p) / 255,
    1301          25 :                 (a.a * (255 - p) + b.a * p) / 255
    1302          25 :         );
    1303             : }
    1304             : 
    1305             : 
    1306     5332255 : bool Color4F::operator==(const Color4F& right) const {
    1307     5332255 :         return (r == right.r && g == right.g && b == right.b && a == right.a);
    1308             : }
    1309             : 
    1310          50 : bool Color4F::operator==(const Color3B& right) const {
    1311          50 :         return (a == 1.0f && Color3B(*this) == right);
    1312             : }
    1313             : 
    1314          50 : bool Color4F::operator==(const Color4B& right) const {
    1315          50 :         return (*this == Color4F(right));
    1316             : }
    1317             : 
    1318     5274510 : bool Color4F::operator!=(const Color4F& right) const {
    1319     5274510 :         return !(*this == right);
    1320             : }
    1321             : 
    1322          25 : bool Color4F::operator!=(const Color3B& right) const {
    1323          25 :         return !(*this == right);
    1324             : }
    1325             : 
    1326          25 : bool Color4F::operator!=(const Color4B& right) const {
    1327          25 :         return !(*this == right);
    1328             : }
    1329             : 
    1330       16512 : Color3B Color4F::getColor() const {
    1331       16512 :         return Color3B(uint8_t(r * 255.0f), uint8_t(g * 255.0f), uint8_t(b * 255.0f));
    1332             : }
    1333             : 
    1334       16512 : uint8_t Color4F::getOpacity() const {
    1335       16512 :         return uint8_t(a * 255.0f);
    1336             : }
    1337             : 
    1338          25 : void Color4F::setMasked(const Color4F &color, ColorMask mask) {
    1339          25 :         if ((mask & ColorMask::R) != ColorMask::None) { r = color.r; }
    1340          25 :         if ((mask & ColorMask::G) != ColorMask::None) { g = color.g; }
    1341          25 :         if ((mask & ColorMask::B) != ColorMask::None) { b = color.b; }
    1342          25 :         if ((mask & ColorMask::A) != ColorMask::None) { a = color.a; }
    1343          25 : }
    1344             : 
    1345          50 : void Color4F::setUnmasked(const Color4F &color, ColorMask mask) {
    1346          50 :         if ((mask & ColorMask::R) == ColorMask::None) { r = color.r; }
    1347          50 :         if ((mask & ColorMask::G) == ColorMask::None) { g = color.g; }
    1348          50 :         if ((mask & ColorMask::B) == ColorMask::None) { b = color.b; }
    1349          50 :         if ((mask & ColorMask::A) == ColorMask::None) { a = color.a; }
    1350          50 : }
    1351             : 
    1352         150 : std::ostream & operator<<(std::ostream & stream, const Color & obj) {
    1353         150 :         stream << "Color:" << obj.name<memory::StandartInterface>() << ";";
    1354         150 :         return stream;
    1355             : }
    1356             : 
    1357          75 : std::ostream & operator<<(std::ostream & stream, const Color3B & obj) {
    1358          75 :         stream << "Color3B(r:" << obj.r << " g:" << obj.g << " b:" << obj.b << ");";
    1359          75 :         return stream;
    1360             : }
    1361             : 
    1362         175 : std::ostream & operator<<(std::ostream & stream, const Color4B & obj) {
    1363         175 :         stream << "Color4B(r:" << obj.r << " g:" << obj.g << " b:" << obj.b << " a:" << obj.a << ");";
    1364         175 :         return stream;
    1365             : }
    1366             : 
    1367         150 : std::ostream & operator<<(std::ostream & stream, const Color4F & obj) {
    1368         150 :         stream << "Color4F(r:" << obj.r << " g:" << obj.g << " b:" << obj.b << " a:" << obj.a << ");";
    1369         150 :         return stream;
    1370             : }
    1371             : 
    1372             : #ifdef __LCC__
    1373             : 
    1374             : constexpr const Color3B Color3B::WHITE(255, 255, 255);
    1375             : constexpr const Color3B Color3B::BLACK(0, 0, 0);
    1376             : 
    1377             : constexpr const Color4B Color4B::WHITE(255, 255, 255, 255);
    1378             : constexpr const Color4B Color4B::BLACK(0, 0, 0, 255);
    1379             : 
    1380             : constexpr const Color4F Color4F::WHITE(1, 1, 1, 1);
    1381             : constexpr const Color4F Color4F::BLACK(0, 0, 0, 1);
    1382             : constexpr const Color4F Color4F::ZERO(0, 0, 0, 0);
    1383             : constexpr const Color4F Color4F::ONE(1, 1, 1, 1);
    1384             : 
    1385             : #endif
    1386             : 
    1387             : }

Generated by: LCOV version 1.14