Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

190 lines
8.7KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - Raw Material Software Limited
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 7 End-User License
  8. Agreement and JUCE Privacy Policy.
  9. End User License Agreement: www.juce.com/juce-7-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. namespace juce
  19. {
  20. //==============================================================================
  21. Colour Colours::findColourForName (const String& colourName,
  22. Colour defaultColour)
  23. {
  24. struct StringHashAndColour { uint32 stringHash, colour; };
  25. static const StringHashAndColour presets[]
  26. {
  27. { 0x05978fff, 0xff000000 }, /* black */
  28. { 0x06bdcc29, 0xffffffff }, /* white */
  29. { 0x002e305a, 0xff0000ff }, /* blue */
  30. { 0x00308adf, 0xff808080 }, /* grey */
  31. { 0x05e0cf03, 0xff008000 }, /* green */
  32. { 0x0001b891, 0xffff0000 }, /* red */
  33. { 0xd43c6474, 0xffffff00 }, /* yellow */
  34. { 0x620886da, 0xfff0f8ff }, /* aliceblue */
  35. { 0x20a2676a, 0xfffaebd7 }, /* antiquewhite */
  36. { 0x002dcebc, 0xff00ffff }, /* aqua */
  37. { 0x46bb5f7e, 0xff7fffd4 }, /* aquamarine */
  38. { 0x0590228f, 0xfff0ffff }, /* azure */
  39. { 0x05947fe4, 0xfff5f5dc }, /* beige */
  40. { 0xad388e35, 0xffffe4c4 }, /* bisque */
  41. { 0x00674f7e, 0xffffebcd }, /* blanchedalmond */
  42. { 0x39129959, 0xff8a2be2 }, /* blueviolet */
  43. { 0x059a8136, 0xffa52a2a }, /* brown */
  44. { 0x89cea8f9, 0xffdeb887 }, /* burlywood */
  45. { 0x0fa260cf, 0xff5f9ea0 }, /* cadetblue */
  46. { 0x6b748956, 0xff7fff00 }, /* chartreuse */
  47. { 0x2903623c, 0xffd2691e }, /* chocolate */
  48. { 0x05a74431, 0xffff7f50 }, /* coral */
  49. { 0x618d42dd, 0xff6495ed }, /* cornflowerblue */
  50. { 0xe4b479fd, 0xfffff8dc }, /* cornsilk */
  51. { 0x3d8c4edf, 0xffdc143c }, /* crimson */
  52. { 0x002ed323, 0xff00ffff }, /* cyan */
  53. { 0x67cc74d0, 0xff00008b }, /* darkblue */
  54. { 0x67cd1799, 0xff008b8b }, /* darkcyan */
  55. { 0x31bbd168, 0xffb8860b }, /* darkgoldenrod */
  56. { 0x67cecf55, 0xff555555 }, /* darkgrey */
  57. { 0x920b194d, 0xff006400 }, /* darkgreen */
  58. { 0x923edd4c, 0xffbdb76b }, /* darkkhaki */
  59. { 0x5c293873, 0xff8b008b }, /* darkmagenta */
  60. { 0x6b6671fe, 0xff556b2f }, /* darkolivegreen */
  61. { 0xbcfd2524, 0xffff8c00 }, /* darkorange */
  62. { 0xbcfdf799, 0xff9932cc }, /* darkorchid */
  63. { 0x55ee0d5b, 0xff8b0000 }, /* darkred */
  64. { 0xc2e5f564, 0xffe9967a }, /* darksalmon */
  65. { 0x61be858a, 0xff8fbc8f }, /* darkseagreen */
  66. { 0xc2b0f2bd, 0xff483d8b }, /* darkslateblue */
  67. { 0xc2b34d42, 0xff2f4f4f }, /* darkslategrey */
  68. { 0x7cf2b06b, 0xff00ced1 }, /* darkturquoise */
  69. { 0xc8769375, 0xff9400d3 }, /* darkviolet */
  70. { 0x25832862, 0xffff1493 }, /* deeppink */
  71. { 0xfcad568f, 0xff00bfff }, /* deepskyblue */
  72. { 0x634c8b67, 0xff696969 }, /* dimgrey */
  73. { 0x45c1ce55, 0xff1e90ff }, /* dodgerblue */
  74. { 0xef19e3cb, 0xffb22222 }, /* firebrick */
  75. { 0xb852b195, 0xfffffaf0 }, /* floralwhite */
  76. { 0xd086fd06, 0xff228b22 }, /* forestgreen */
  77. { 0xe106b6d7, 0xffff00ff }, /* fuchsia */
  78. { 0x7880d61e, 0xffdcdcdc }, /* gainsboro */
  79. { 0x2018a2fa, 0xfff8f8ff }, /* ghostwhite */
  80. { 0x00308060, 0xffffd700 }, /* gold */
  81. { 0xb3b3bc1e, 0xffdaa520 }, /* goldenrod */
  82. { 0xbab8a537, 0xffadff2f }, /* greenyellow */
  83. { 0xe4cacafb, 0xfff0fff0 }, /* honeydew */
  84. { 0x41892743, 0xffff69b4 }, /* hotpink */
  85. { 0xd5796f1a, 0xffcd5c5c }, /* indianred */
  86. { 0xb969fed2, 0xff4b0082 }, /* indigo */
  87. { 0x05fef6a9, 0xfffffff0 }, /* ivory */
  88. { 0x06149302, 0xfff0e68c }, /* khaki */
  89. { 0xad5a05c7, 0xffe6e6fa }, /* lavender */
  90. { 0x7c4d5b99, 0xfffff0f5 }, /* lavenderblush */
  91. { 0x41cc4377, 0xff7cfc00 }, /* lawngreen */
  92. { 0x195756f0, 0xfffffacd }, /* lemonchiffon */
  93. { 0x28e4ea70, 0xffadd8e6 }, /* lightblue */
  94. { 0xf3c7ccdb, 0xfff08080 }, /* lightcoral */
  95. { 0x28e58d39, 0xffe0ffff }, /* lightcyan */
  96. { 0x21234e3c, 0xfffafad2 }, /* lightgoldenrodyellow */
  97. { 0xf40157ad, 0xff90ee90 }, /* lightgreen */
  98. { 0x28e744f5, 0xffd3d3d3 }, /* lightgrey */
  99. { 0x28eb3b8c, 0xffffb6c1 }, /* lightpink */
  100. { 0x9fb78304, 0xffffa07a }, /* lightsalmon */
  101. { 0x50632b2a, 0xff20b2aa }, /* lightseagreen */
  102. { 0x68fb7b25, 0xff87cefa }, /* lightskyblue */
  103. { 0xa8a35ba2, 0xff778899 }, /* lightslategrey */
  104. { 0xa20d484f, 0xffb0c4de }, /* lightsteelblue */
  105. { 0xaa2cf10a, 0xffffffe0 }, /* lightyellow */
  106. { 0x0032afd5, 0xff00ff00 }, /* lime */
  107. { 0x607bbc4e, 0xff32cd32 }, /* limegreen */
  108. { 0x06234efa, 0xfffaf0e6 }, /* linen */
  109. { 0x316858a9, 0xffff00ff }, /* magenta */
  110. { 0xbf8ca470, 0xff800000 }, /* maroon */
  111. { 0xbd58e0b3, 0xff66cdaa }, /* mediumaquamarine */
  112. { 0x967dfd4f, 0xff0000cd }, /* mediumblue */
  113. { 0x056f5c58, 0xffba55d3 }, /* mediumorchid */
  114. { 0x07556b71, 0xff9370db }, /* mediumpurple */
  115. { 0x5369b689, 0xff3cb371 }, /* mediumseagreen */
  116. { 0x066be19e, 0xff7b68ee }, /* mediumslateblue */
  117. { 0x3256b281, 0xff00fa9a }, /* mediumspringgreen */
  118. { 0xc0ad9f4c, 0xff48d1cc }, /* mediumturquoise */
  119. { 0x628e63dd, 0xffc71585 }, /* mediumvioletred */
  120. { 0x168eb32a, 0xff191970 }, /* midnightblue */
  121. { 0x4306b960, 0xfff5fffa }, /* mintcream */
  122. { 0x4cbc0e6b, 0xffffe4e1 }, /* mistyrose */
  123. { 0xd9447d59, 0xffffe4b5 }, /* moccasin */
  124. { 0xe97218a6, 0xffffdead }, /* navajowhite */
  125. { 0x00337bb6, 0xff000080 }, /* navy */
  126. { 0xadd2d33e, 0xfffdf5e6 }, /* oldlace */
  127. { 0x064ee1db, 0xff808000 }, /* olive */
  128. { 0x9e33a98a, 0xff6b8e23 }, /* olivedrab */
  129. { 0xc3de262e, 0xffffa500 }, /* orange */
  130. { 0x58bebba3, 0xffff4500 }, /* orangered */
  131. { 0xc3def8a3, 0xffda70d6 }, /* orchid */
  132. { 0x28cb4834, 0xffeee8aa }, /* palegoldenrod */
  133. { 0x3d9dd619, 0xff98fb98 }, /* palegreen */
  134. { 0x74022737, 0xffafeeee }, /* paleturquoise */
  135. { 0x15e2ebc8, 0xffdb7093 }, /* palevioletred */
  136. { 0x5fd898e2, 0xffffefd5 }, /* papayawhip */
  137. { 0x93e1b776, 0xffffdab9 }, /* peachpuff */
  138. { 0x003472f8, 0xffcd853f }, /* peru */
  139. { 0x00348176, 0xffffc0cb }, /* pink */
  140. { 0x00348d94, 0xffdda0dd }, /* plum */
  141. { 0xd036be93, 0xffb0e0e6 }, /* powderblue */
  142. { 0xc5c507bc, 0xff800080 }, /* purple */
  143. { 0xf381f607, 0xff663399 }, /* rebeccapurple */
  144. { 0xa89d65b3, 0xffbc8f8f }, /* rosybrown */
  145. { 0xbd9413e1, 0xff4169e1 }, /* royalblue */
  146. { 0xf456044f, 0xff8b4513 }, /* saddlebrown */
  147. { 0xc9c6f66e, 0xfffa8072 }, /* salmon */
  148. { 0x0bb131e1, 0xfff4a460 }, /* sandybrown */
  149. { 0x34636c14, 0xff2e8b57 }, /* seagreen */
  150. { 0x3507fb41, 0xfffff5ee }, /* seashell */
  151. { 0xca348772, 0xffa0522d }, /* sienna */
  152. { 0xca37d30d, 0xffc0c0c0 }, /* silver */
  153. { 0x80da74fb, 0xff87ceeb }, /* skyblue */
  154. { 0x44a8dd73, 0xff6a5acd }, /* slateblue */
  155. { 0x44ab37f8, 0xff708090 }, /* slategrey */
  156. { 0x0035f183, 0xfffffafa }, /* snow */
  157. { 0xd5440d16, 0xff00ff7f }, /* springgreen */
  158. { 0x3e1524a5, 0xff4682b4 }, /* steelblue */
  159. { 0x0001bfa1, 0xffd2b48c }, /* tan */
  160. { 0x0036425c, 0xff008080 }, /* teal */
  161. { 0xafc8858f, 0xffd8bfd8 }, /* thistle */
  162. { 0xcc41600a, 0xffff6347 }, /* tomato */
  163. { 0xfeea9b21, 0xff40e0d0 }, /* turquoise */
  164. { 0xcf57947f, 0xffee82ee }, /* violet */
  165. { 0x06bdbae7, 0xfff5deb3 }, /* wheat */
  166. { 0x10802ee6, 0xfff5f5f5 }, /* whitesmoke */
  167. { 0xe1b5130f, 0xff9acd32 }, /* yellowgreen */
  168. };
  169. const auto hash = (uint32) colourName.trim().toLowerCase().hashCode();
  170. for (auto entry : presets)
  171. if (entry.stringHash == hash)
  172. return Colour (entry.colour);
  173. return defaultColour;
  174. }
  175. } // namespace juce