Color to RGB value table in Lua


/ Published in: Lua
Save to your folder(s)



Copy this code and paste it in your HTML
  1. -- Color to RGB value table for Lua coding with Corona
  2. -- Color values copied from "http://www.w3.org/TR/SVG/types.html#ColorKeywords"
  3. --
  4. -- Usage for Corona toolkit:
  5. -- add this file "colors-rgb.lua" to your working directory
  6. -- add following directive to any file that will use the colors by name:
  7. -- require "colors-rgb"
  8. --
  9. -- in the code, instead of using for example "{210, 105, 30}" for the "chocolate" color,
  10. -- use "colorsRGB.chocolate" or colorsRGB[chocolate]
  11. -- or if you need the individual R,G,B values, you can use either:
  12. -- colorsRGB.chocolate[1] or colorsRGB.R("chocolate") for the R-value
  13. -- or if you need the RGB values for a function list, you can use
  14. -- colorsRGB.RGB("chocolate") that returns the multi value list "210 105 30"
  15. -- this can be used for input in for example "body:setFillColor()", like:
  16. -- body:setFillColor(colorsRGB.RGB("chocolate"))
  17. --
  18. -- Enjoy, Frank (Sep 19, 2010)
  19.  
  20.  
  21. colorsRGB = {
  22. aliceblue = {240, 248, 255},
  23. antiquewhite = {250, 235, 215},
  24. aqua = { 0, 255, 255},
  25. aquamarine = {127, 255, 212},
  26. azure = {240, 255, 255},
  27. beige = {245, 245, 220},
  28. bisque = {255, 228, 196},
  29. black = { 0, 0, 0},
  30. blanchedalmond = {255, 235, 205},
  31. blue = { 0, 0, 255},
  32. blueviolet = {138, 43, 226},
  33. brown = {165, 42, 42},
  34. burlywood = {222, 184, 135},
  35. cadetblue = { 95, 158, 160},
  36. chartreuse = {127, 255, 0},
  37. chocolate = {210, 105, 30},
  38. coral = {255, 127, 80},
  39. cornflowerblue = {100, 149, 237},
  40. cornsilk = {255, 248, 220},
  41. crimson = {220, 20, 60},
  42. cyan = { 0, 255, 255},
  43. darkblue = { 0, 0, 139},
  44. darkcyan = { 0, 139, 139},
  45. darkgoldenrod = {184, 134, 11},
  46. darkgray = {169, 169, 169},
  47. darkgreen = { 0, 100, 0},
  48. darkgrey = {169, 169, 169},
  49. darkkhaki = {189, 183, 107},
  50. darkmagenta = {139, 0, 139},
  51. darkolivegreen = { 85, 107, 47},
  52. darkorange = {255, 140, 0},
  53. darkorchid = {153, 50, 204},
  54. darkred = {139, 0, 0},
  55. darksalmon = {233, 150, 122},
  56. darkseagreen = {143, 188, 143},
  57. darkslateblue = { 72, 61, 139},
  58. darkslategray = { 47, 79, 79},
  59. darkslategrey = { 47, 79, 79},
  60. darkturquoise = { 0, 206, 209},
  61. darkviolet = {148, 0, 211},
  62. deeppink = {255, 20, 147},
  63. deepskyblue = { 0, 191, 255},
  64. dimgray = {105, 105, 105},
  65. dimgrey = {105, 105, 105},
  66. dodgerblue = { 30, 144, 255},
  67. firebrick = {178, 34, 34},
  68. floralwhite = {255, 250, 240},
  69. forestgreen = { 34, 139, 34},
  70. fuchsia = {255, 0, 255},
  71. gainsboro = {220, 220, 220},
  72. ghostwhite = {248, 248, 255},
  73. gold = {255, 215, 0},
  74. goldenrod = {218, 165, 32},
  75. gray = {128, 128, 128},
  76. grey = {128, 128, 128},
  77. green = { 0, 128, 0},
  78. greenyellow = {173, 255, 47},
  79. honeydew = {240, 255, 240},
  80. hotpink = {255, 105, 180},
  81. indianred = {205, 92, 92},
  82. indigo = { 75, 0, 130},
  83. ivory = {255, 255, 240},
  84. khaki = {240, 230, 140},
  85. lavender = {230, 230, 250},
  86. lavenderblush = {255, 240, 245},
  87. lawngreen = {124, 252, 0},
  88. lemonchiffon = {255, 250, 205},
  89. lightblue = {173, 216, 230},
  90. lightcoral = {240, 128, 128},
  91. lightcyan = {224, 255, 255},
  92. lightgoldenrodyellow = {250, 250, 210},
  93. lightgray = {211, 211, 211},
  94. lightgreen = {144, 238, 144},
  95. lightgrey = {211, 211, 211},
  96. lightpink = {255, 182, 193},
  97. lightsalmon = {255, 160, 122},
  98. lightseagreen = { 32, 178, 170},
  99. lightskyblue = {135, 206, 250},
  100. lightslategray = {119, 136, 153},
  101. lightslategrey = {119, 136, 153},
  102. lightsteelblue = {176, 196, 222},
  103. lightyellow = {255, 255, 224},
  104. lime = { 0, 255, 0},
  105. limegreen = { 50, 205, 50},
  106. linen = {250, 240, 230},
  107. magenta = {255, 0, 255},
  108. maroon = {128, 0, 0},
  109. mediumaquamarine = {102, 205, 170},
  110. mediumblue = { 0, 0, 205},
  111. mediumorchid = {186, 85, 211},
  112. mediumpurple = {147, 112, 219},
  113. mediumseagreen = { 60, 179, 113},
  114. mediumslateblue = {123, 104, 238},
  115. mediumspringgreen = { 0, 250, 154},
  116. mediumturquoise = { 72, 209, 204},
  117. mediumvioletred = {199, 21, 133},
  118. midnightblue = { 25, 25, 112},
  119. mintcream = {245, 255, 250},
  120. mistyrose = {255, 228, 225},
  121. moccasin = {255, 228, 181},
  122. navajowhite = {255, 222, 173},
  123. navy = { 0, 0, 128},
  124. oldlace = {253, 245, 230},
  125. olive = {128, 128, 0},
  126. olivedrab = {107, 142, 35},
  127. orange = {255, 165, 0},
  128. orangered = {255, 69, 0},
  129. orchid = {218, 112, 214},
  130. palegoldenrod = {238, 232, 170},
  131. palegreen = {152, 251, 152},
  132. paleturquoise = {175, 238, 238},
  133. palevioletred = {219, 112, 147},
  134. papayawhip = {255, 239, 213},
  135. peachpuff = {255, 218, 185},
  136. peru = {205, 133, 63},
  137. pink = {255, 192, 203},
  138. plum = {221, 160, 221},
  139. powderblue = {176, 224, 230},
  140. purple = {128, 0, 128},
  141. red = {255, 0, 0},
  142. rosybrown = {188, 143, 143},
  143. royalblue = { 65, 105, 225},
  144. saddlebrown = {139, 69, 19},
  145. salmon = {250, 128, 114},
  146. sandybrown = {244, 164, 96},
  147. seagreen = { 46, 139, 87},
  148. seashell = {255, 245, 238},
  149. sienna = {160, 82, 45},
  150. silver = {192, 192, 192},
  151. skyblue = {135, 206, 235},
  152. slateblue = {106, 90, 205},
  153. slategray = {112, 128, 144},
  154. slategrey = {112, 128, 144},
  155. snow = {255, 250, 250},
  156. springgreen = { 0, 255, 127},
  157. steelblue = { 70, 130, 180},
  158. tan = {210, 180, 140},
  159. teal = { 0, 128, 128},
  160. thistle = {216, 191, 216},
  161. tomato = {255, 99, 71},
  162. turquoise = { 64, 224, 208},
  163. violet = {238, 130, 238},
  164. wheat = {245, 222, 179},
  165. white = {255, 255, 255},
  166. whitesmoke = {245, 245, 245},
  167. yellow = {255, 255, 0},
  168. yellowgreen = {154, 205, 50}
  169. }
  170.  
  171. colorsRGB.R = function (name)
  172. return colorsRGB[name][1]
  173. end
  174.  
  175. colorsRGB.G = function (name)
  176. return colorsRGB[name][2]
  177. end
  178.  
  179. colorsRGB.B = function (name)
  180. return colorsRGB[name][3]
  181. end
  182.  
  183. colorsRGB.RGB = function (name)
  184. return colorsRGB[name][1],colorsRGB[name][2],colorsRGB[name][3]
  185. end

URL: https://developer.anscamobile.com/forum/2010/09/20/table-common-named-colors-rgb-numbers

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.