Advertisement
Anatoly03

Colors v7

Nov 10th, 2019
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 42.13 KB | None | 0 0
  1.  
  2. --# Colors
  3.  
  4.  
  5.  
  6.  
  7. --[[
  8.  
  9. Name: Colors
  10. Author: Anatoly
  11. License: ISC
  12. Description: Colors is a library, that manipulates colors.
  13. Thread: https://codea.io/talk/discussion/10043/colors
  14. Release: 7
  15.  
  16. Main:
  17. - Huge Update! Completely rebuild design.
  18. - Project Logo Autogenerated!
  19.  
  20. Colors
  21. - "orangered" revamped
  22. - "_colors" variable no longer! "colors" stays the only hard coded stuff!
  23. - every origin now supports "-10" to "-90" suffix.
  24.  
  25. ]]
  26.  
  27. colors = {}
  28.  
  29. do
  30.  
  31. local colors1 = {}
  32.  
  33. -- Origins
  34. colors1["red"] = color(255, 0, 0, 255)
  35. colors1["orangered"] = color(255, 80, 0, 255)
  36. colors1["orange"] = color(255, 150, 0, 255)
  37. colors1["brown"] = color(200, 115, 45, 255)
  38. colors1["darkbrown"] = color(115, 75, 40, 255)
  39. colors1["strawberry-red"] = color(223, 85, 111, 255)
  40. colors1["yellow"] = color(255, 255, 0, 255)
  41. colors1["gold"] = color(225, 180, 60, 255)
  42. colors1["bronze"] = color(190, 155, 90, 255)
  43. colors1["forestgreen"] = color(0, 155, 0, 255)
  44. colors1["middlegreen"] = color(150, 155, 0, 255)
  45. colors1["green"] = color(0, 255, 0, 255)
  46. colors1["grassgreen"] = color(150, 255, 0, 255)
  47. colors1["turquoise"] = color(0, 255, 150, 255)
  48. colors1["neon-green"] = color(210, 255, 0, 255)
  49. colors1["blue"] = color(0, 0, 255, 255)
  50. colors1["skyblue"] = color(0, 150, 255, 255)
  51. colors1["seablue"] = color(50, 200, 255)
  52. colors1["diamondblue"] = color(95, 170, 225, 255)
  53. colors1["cyan"] = color(0, 255, 255, 255)
  54. colors1["silver"] = color(180, 210, 210, 255)
  55. colors1["cold-white"] = color(192, 212, 225, 255)
  56. colors1["warm-white"] = color(228, 223, 207, 255)
  57. colors1["purple"] = color(160, 0, 255, 255)
  58. colors1["rosa"] = color(255, 0, 150, 255)
  59. colors1["magenta"] = color(255, 0, 255, 255)
  60. colors1["pink"] = color(255, 150, 255, 255)
  61. colors1["violet"] = color(125, 0, 255, 255)
  62. colors1["darkviolet"] = color(150, 25, 120, 255)
  63.  
  64. -- SVG, X11
  65. -- Author: Andrew Stacey, adopted by Anatoly
  66. -- Website: http://www.math.ntnu.no/~stacey/HowDidIDoThat/iPad/Codea.html
  67. -- Source: https://github.com/loopspace/Codea-Library-Base/blob/master/ColourExt.lua
  68. -- Licence: CC0 (http://wiki.creativecommons.org/CC0)
  69.  
  70. -- SVG
  71.  
  72. local schema = {}
  73.  
  74. schema.svg = {}
  75. schema.svg.AliceBlue = color(239,247,255,255)
  76. schema.svg.AntiqueWhite = color(249,234,215,255)
  77. schema.svg.Aqua = color(0,255,255,255)
  78. schema.svg.Aquamarine = color(126,255,211,255)
  79. schema.svg.Azure = color(239,255,255,255)
  80. schema.svg.Beige = color(244,244,220,255)
  81. schema.svg.Bisque = color(255,227,196,255)
  82. schema.svg.Black = color(0,0,0,255)
  83. schema.svg.BlanchedAlmond = color(255,234,205,255)
  84. schema.svg.Blue = color(0,0,255,255)
  85. schema.svg.BlueViolet = color(137,43,226,255)
  86. schema.svg.Brown = color(165,42,42,255)
  87. schema.svg.BurlyWood = color(221,183,135,255)
  88. schema.svg.CadetBlue = color(94,158,160,255)
  89. schema.svg.Chartreuse = color(126,255,0,255)
  90. schema.svg.Chocolate = color(210,104,29,255)
  91. schema.svg.Coral = color(255,126,79,255)
  92. schema.svg.CornflowerBlue = color(99,149,237,255)
  93. schema.svg.Cornsilk = color(255,247,220,255)
  94. schema.svg.Crimson = color(220,20,59,255)
  95. schema.svg.Cyan = color(0,255,255,255)
  96. schema.svg.DarkBlue = color(0,0,138,255)
  97. schema.svg.DarkCyan = color(0,138,138,255)
  98. schema.svg.DarkGoldenrod = color(183,133,11,255)
  99. schema.svg.DarkGray = color(169,169,169,255)
  100. schema.svg.DarkGreen = color(0,99,0,255)
  101. schema.svg.DarkGrey = color(169,169,169,255)
  102. schema.svg.DarkKhaki = color(188,182,107,255)
  103. schema.svg.DarkMagenta = color(138,0,138,255)
  104. schema.svg.DarkOliveGreen = color(84,107,47,255)
  105. schema.svg.DarkOrange = color(255,140,0,255)
  106. schema.svg.DarkOrchid = color(183,49,204,255)
  107. schema.svg.DarkRed = color(138,0,0,255)
  108. schema.svg.DarkSalmon = color(232,150,122,255)
  109. schema.svg.DarkSeaGreen = color(142,187,142,255)
  110. schema.svg.DarkSlateBlue = color(72,61,138,255)
  111. schema.svg.DarkSlateGray = color(47,79,79,255)
  112. schema.svg.DarkSlateGrey = color(47,79,79,255)
  113. schema.svg.DarkTurquoise = color(0,206,209,255)
  114. schema.svg.DarkViolet = color(147,0,211,255)
  115. schema.svg.DeepPink = color(255,20,146,255)
  116. schema.svg.DeepSkyBlue = color(0,191,255,255)
  117. schema.svg.DimGray = color(104,104,104,255)
  118. schema.svg.DimGrey = color(104,104,104,255)
  119. schema.svg.DodgerBlue = color(29,144,255,255)
  120. schema.svg.FireBrick = color(177,33,33,255)
  121. schema.svg.FloralWhite = color(255,249,239,255)
  122. schema.svg.ForestGreen = color(33,138,33,255)
  123. schema.svg.Fuchsia = color(255,0,255,255)
  124. schema.svg.Gainsboro = color(220,220,220,255)
  125. schema.svg.GhostWhite = color(247,247,255,255)
  126. schema.svg.Gold = color(255,215,0,255)
  127. schema.svg.Goldenrod = color(218,165,31,255)
  128. schema.svg.Gray = color(127,127,127,255)
  129. schema.svg.Green = color(0,127,0,255)
  130. schema.svg.GreenYellow = color(173,255,47,255)
  131. schema.svg.Grey = color(127,127,127,255)
  132. schema.svg.Honeydew = color(239,255,239,255)
  133. schema.svg.HotPink = color(255,104,179,255)
  134. schema.svg.IndianRed = color(205,91,91,255)
  135. schema.svg.Indigo = color(74,0,130,255)
  136. schema.svg.Ivory = color(255,255,239,255)
  137. schema.svg.Khaki = color(239,229,140,255)
  138. schema.svg.Lavender = color(229,229,249,255)
  139. schema.svg.LavenderBlush = color(255,239,244,255)
  140. schema.svg.LawnGreen = color(124,252,0,255)
  141. schema.svg.LemonChiffon = color(255,249,205,255)
  142. schema.svg.LightBlue = color(173,216,229,255)
  143. schema.svg.LightCoral = color(239,127,127,255)
  144. schema.svg.LightCyan = color(224,255,255,255)
  145. schema.svg.LightGoldenrod = color(237,221,130,255)
  146. schema.svg.LightGoldenrodYellow = color(249,249,210,255)
  147. schema.svg.LightGray = color(211,211,211,255)
  148. schema.svg.LightGreen = color(144,237,144,255)
  149. schema.svg.LightGrey = color(211,211,211,255)
  150. schema.svg.LightPink = color(255,181,192,255)
  151. schema.svg.LightSalmon = color(255,160,122,255)
  152. schema.svg.LightSeaGreen = color(31,177,170,255)
  153. schema.svg.LightSkyBlue = color(135,206,249,255)
  154. schema.svg.LightSlateBlue = color(132,112,255,255)
  155. schema.svg.LightSlateGray = color(119,135,153,255)
  156. schema.svg.LightSlateGrey = color(119,135,153,255)
  157. schema.svg.LightSteelBlue = color(175,196,221,255)
  158. schema.svg.LightYellow = color(255,255,224,255)
  159. schema.svg.Lime = color(0,255,0,255)
  160. schema.svg.LimeGreen = color(49,205,49,255)
  161. schema.svg.Linen = color(249,239,229,255)
  162. schema.svg.Magenta = color(255,0,255,255)
  163. schema.svg.Maroon = color(127,0,0,255)
  164. schema.svg.MediumAquamarine = color(102,205,170,255)
  165. schema.svg.MediumBlue = color(0,0,205,255)
  166. schema.svg.MediumOrchid = color(186,84,211,255)
  167. schema.svg.MediumPurple = color(146,112,219,255)
  168. schema.svg.MediumSeaGreen = color(59,178,113,255)
  169. schema.svg.MediumSlateBlue = color(123,104,237,255)
  170. schema.svg.MediumSpringGreen = color(0,249,154,255)
  171. schema.svg.MediumTurquoise = color(72,209,204,255)
  172. schema.svg.MediumVioletRed = color(198,21,132,255)
  173. schema.svg.MidnightBlue = color(24,24,112,255)
  174. schema.svg.MintCream = color(244,255,249,255)
  175. schema.svg.MistyRose = color(255,227,225,255)
  176. schema.svg.Moccasin = color(255,227,181,255)
  177. schema.svg.NavajoWhite = color(255,221,173,255)
  178. schema.svg.Navy = color(0,0,127,255)
  179. schema.svg.NavyBlue = color(0,0,127,255)
  180. schema.svg.OldLace = color(252,244,229,255)
  181. schema.svg.Olive = color(127,127,0,255)
  182. schema.svg.OliveDrab = color(107,141,34,255)
  183. schema.svg.Orange = color(255,165,0,255)
  184. schema.svg.OrangeRed = color(255,68,0,255)
  185. schema.svg.Orchid = color(218,112,214,255)
  186. schema.svg.PaleGoldenrod = color(237,232,170,255)
  187. schema.svg.PaleGreen = color(151,251,151,255)
  188. schema.svg.PaleTurquoise = color(175,237,237,255)
  189. schema.svg.PaleVioletRed = color(219,112,146,255)
  190. schema.svg.PapayaWhip = color(255,238,212,255)
  191. schema.svg.PeachPuff = color(255,218,184,255)
  192. schema.svg.Peru = color(205,132,63,255)
  193. schema.svg.Pink = color(255,191,202,255)
  194. schema.svg.Plum = color(221,160,221,255)
  195. schema.svg.PowderBlue = color(175,224,229,255)
  196. schema.svg.Purple = color(127,0,127,255)
  197. schema.svg.Red = color(255,0,0,255)
  198. schema.svg.RosyBrown = color(187,142,142,255)
  199. schema.svg.RoyalBlue = color(65,104,225,255)
  200. schema.svg.SaddleBrown = color(138,68,19,255)
  201. schema.svg.Salmon = color(249,127,114,255)
  202. schema.svg.SandyBrown = color(243,164,95,255)
  203. schema.svg.SeaGreen = color(45,138,86,255)
  204. schema.svg.Seashell = color(255,244,237,255)
  205. schema.svg.Sienna = color(160,81,44,255)
  206. schema.svg.Silver = color(191,191,191,255)
  207. schema.svg.SkyBlue = color(135,206,234,255)
  208. schema.svg.SlateBlue = color(105,89,205,255)
  209. schema.svg.SlateGray = color(112,127,144,255)
  210. schema.svg.SlateGrey = color(112,127,144,255)
  211. schema.svg.Snow = color(255,249,249,255)
  212. schema.svg.SpringGreen = color(0,255,126,255)
  213. schema.svg.SteelBlue = color(70,130,179,255)
  214. schema.svg.Tan = color(210,179,140,255)
  215. schema.svg.Teal = color(0,127,127,255)
  216. schema.svg.Thistle = color(216,191,216,255)
  217. schema.svg.Tomato = color(255,99,71,255)
  218. schema.svg.Turquoise = color(63,224,207,255)
  219. schema.svg.Violet = color(237,130,237,255)
  220. schema.svg.VioletRed = color(208,31,144,255)
  221. schema.svg.Wheat = color(244,221,178,255)
  222. schema.svg.White = color(255,255,255,255)
  223. schema.svg.WhiteSmoke = color(244,244,244,255)
  224. schema.svg.Yellow = color(255,255,0,255)
  225. schema.svg.YellowGreen = color(154,205,49,255)
  226.  
  227. for a, b in pairs(schema.svg) do
  228. colors["svg-" .. string.lower(a)] = b
  229. end
  230.  
  231. -- X11
  232.  
  233. schema.x11 = {}
  234. schema.x11.AntiqueWhite1 = color(255,238,219,255)
  235. schema.x11.AntiqueWhite2 = color(237,223,204,255)
  236. schema.x11.AntiqueWhite3 = color(205,191,175,255)
  237. schema.x11.AntiqueWhite4 = color(138,130,119,255)
  238. schema.x11.Aquamarine1 = color(126,255,211,255)
  239. schema.x11.Aquamarine2 = color(118,237,197,255)
  240. schema.x11.Aquamarine3 = color(102,205,170,255)
  241. schema.x11.Aquamarine4 = color(68,138,116,255)
  242. schema.x11.Azure1 = color(239,255,255,255)
  243. schema.x11.Azure2 = color(224,237,237,255)
  244. schema.x11.Azure3 = color(192,205,205,255)
  245. schema.x11.Azure4 = color(130,138,138,255)
  246. schema.x11.Bisque1 = color(255,227,196,255)
  247. schema.x11.Bisque2 = color(237,212,182,255)
  248. schema.x11.Bisque3 = color(205,182,158,255)
  249. schema.x11.Bisque4 = color(138,124,107,255)
  250. schema.x11.Blue1 = color(0,0,255,255)
  251. schema.x11.Blue2 = color(0,0,237,255)
  252. schema.x11.Blue3 = color(0,0,205,255)
  253. schema.x11.Blue4 = color(0,0,138,255)
  254. schema.x11.Brown1 = color(255,63,63,255)
  255. schema.x11.Brown2 = color(237,58,58,255)
  256. schema.x11.Brown3 = color(205,51,51,255)
  257. schema.x11.Brown4 = color(138,34,34,255)
  258. schema.x11.Burlywood1 = color(255,211,155,255)
  259. schema.x11.Burlywood2 = color(237,196,145,255)
  260. schema.x11.Burlywood3 = color(205,170,124,255)
  261. schema.x11.Burlywood4 = color(138,114,84,255)
  262. schema.x11.CadetBlue1 = color(151,244,255,255)
  263. schema.x11.CadetBlue2 = color(141,228,237,255)
  264. schema.x11.CadetBlue3 = color(122,196,205,255)
  265. schema.x11.CadetBlue4 = color(82,133,138,255)
  266. schema.x11.Chartreuse1 = color(126,255,0,255)
  267. schema.x11.Chartreuse2 = color(118,237,0,255)
  268. schema.x11.Chartreuse3 = color(102,205,0,255)
  269. schema.x11.Chartreuse4 = color(68,138,0,255)
  270. schema.x11.Chocolate1 = color(255,126,35,255)
  271. schema.x11.Chocolate2 = color(237,118,33,255)
  272. schema.x11.Chocolate3 = color(205,102,28,255)
  273. schema.x11.Chocolate4 = color(138,68,19,255)
  274. schema.x11.Coral1 = color(255,114,85,255)
  275. schema.x11.Coral2 = color(237,105,79,255)
  276. schema.x11.Coral3 = color(205,90,68,255)
  277. schema.x11.Coral4 = color(138,62,47,255)
  278. schema.x11.Cornsilk1 = color(255,247,220,255)
  279. schema.x11.Cornsilk2 = color(237,232,205,255)
  280. schema.x11.Cornsilk3 = color(205,200,176,255)
  281. schema.x11.Cornsilk4 = color(138,135,119,255)
  282. schema.x11.Cyan1 = color(0,255,255,255)
  283. schema.x11.Cyan2 = color(0,237,237,255)
  284. schema.x11.Cyan3 = color(0,205,205,255)
  285. schema.x11.Cyan4 = color(0,138,138,255)
  286. schema.x11.DarkGoldenrod1 = color(255,184,15,255)
  287. schema.x11.DarkGoldenrod2 = color(237,173,14,255)
  288. schema.x11.DarkGoldenrod3 = color(205,149,12,255)
  289. schema.x11.DarkGoldenrod4 = color(138,100,7,255)
  290. schema.x11.DarkOliveGreen1 = color(201,255,112,255)
  291. schema.x11.DarkOliveGreen2 = color(187,237,104,255)
  292. schema.x11.DarkOliveGreen3 = color(161,205,89,255)
  293. schema.x11.DarkOliveGreen4 = color(109,138,61,255)
  294. schema.x11.DarkOrange1 = color(255,126,0,255)
  295. schema.x11.DarkOrange2 = color(237,118,0,255)
  296. schema.x11.DarkOrange3 = color(205,102,0,255)
  297. schema.x11.DarkOrange4 = color(138,68,0,255)
  298. schema.x11.DarkOrchid1 = color(191,62,255,255)
  299. schema.x11.DarkOrchid2 = color(177,58,237,255)
  300. schema.x11.DarkOrchid3 = color(154,49,205,255)
  301. schema.x11.DarkOrchid4 = color(104,33,138,255)
  302. schema.x11.DarkSeaGreen1 = color(192,255,192,255)
  303. schema.x11.DarkSeaGreen2 = color(179,237,179,255)
  304. schema.x11.DarkSeaGreen3 = color(155,205,155,255)
  305. schema.x11.DarkSeaGreen4 = color(104,138,104,255)
  306. schema.x11.DarkSlateGray1 = color(150,255,255,255)
  307. schema.x11.DarkSlateGray2 = color(140,237,237,255)
  308. schema.x11.DarkSlateGray3 = color(121,205,205,255)
  309. schema.x11.DarkSlateGray4 = color(81,138,138,255)
  310. schema.x11.DeepPink1 = color(255,20,146,255)
  311. schema.x11.DeepPink2 = color(237,17,136,255)
  312. schema.x11.DeepPink3 = color(205,16,118,255)
  313. schema.x11.DeepPink4 = color(138,10,79,255)
  314. schema.x11.DeepSkyBlue1 = color(0,191,255,255)
  315. schema.x11.DeepSkyBlue2 = color(0,177,237,255)
  316. schema.x11.DeepSkyBlue3 = color(0,154,205,255)
  317. schema.x11.DeepSkyBlue4 = color(0,104,138,255)
  318. schema.x11.DodgerBlue1 = color(29,144,255,255)
  319. schema.x11.DodgerBlue2 = color(28,133,237,255)
  320. schema.x11.DodgerBlue3 = color(23,116,205,255)
  321. schema.x11.DodgerBlue4 = color(16,77,138,255)
  322. schema.x11.Firebrick1 = color(255,48,48,255)
  323. schema.x11.Firebrick2 = color(237,43,43,255)
  324. schema.x11.Firebrick3 = color(205,38,38,255)
  325. schema.x11.Firebrick4 = color(138,25,25,255)
  326. schema.x11.Gold1 = color(255,215,0,255)
  327. schema.x11.Gold2 = color(237,201,0,255)
  328. schema.x11.Gold3 = color(205,173,0,255)
  329. schema.x11.Gold4 = color(138,117,0,255)
  330. schema.x11.Goldenrod1 = color(255,192,36,255)
  331. schema.x11.Goldenrod2 = color(237,179,33,255)
  332. schema.x11.Goldenrod3 = color(205,155,28,255)
  333. schema.x11.Goldenrod4 = color(138,104,20,255)
  334. schema.x11.Green1 = color(0,255,0,255)
  335. schema.x11.Green2 = color(0,237,0,255)
  336. schema.x11.Green3 = color(0,205,0,255)
  337. schema.x11.Green4 = color(0,138,0,255)
  338. schema.x11.Honeydew1 = color(239,255,239,255)
  339. schema.x11.Honeydew2 = color(224,237,224,255)
  340. schema.x11.Honeydew3 = color(192,205,192,255)
  341. schema.x11.Honeydew4 = color(130,138,130,255)
  342. schema.x11.HotPink1 = color(255,109,179,255)
  343. schema.x11.HotPink2 = color(237,105,167,255)
  344. schema.x11.HotPink3 = color(205,95,144,255)
  345. schema.x11.HotPink4 = color(138,58,98,255)
  346. schema.x11.IndianRed1 = color(255,105,105,255)
  347. schema.x11.IndianRed2 = color(237,99,99,255)
  348. schema.x11.IndianRed3 = color(205,84,84,255)
  349. schema.x11.IndianRed4 = color(138,58,58,255)
  350. schema.x11.Ivory1 = color(255,255,239,255)
  351. schema.x11.Ivory2 = color(237,237,224,255)
  352. schema.x11.Ivory3 = color(205,205,192,255)
  353. schema.x11.Ivory4 = color(138,138,130,255)
  354. schema.x11.Khaki1 = color(255,246,142,255)
  355. schema.x11.Khaki2 = color(237,229,132,255)
  356. schema.x11.Khaki3 = color(205,197,114,255)
  357. schema.x11.Khaki4 = color(138,133,77,255)
  358. schema.x11.LavenderBlush1 = color(255,239,244,255)
  359. schema.x11.LavenderBlush2 = color(237,224,228,255)
  360. schema.x11.LavenderBlush3 = color(205,192,196,255)
  361. schema.x11.LavenderBlush4 = color(138,130,133,255)
  362. schema.x11.LemonChiffon1 = color(255,249,205,255)
  363. schema.x11.LemonChiffon2 = color(237,232,191,255)
  364. schema.x11.LemonChiffon3 = color(205,201,165,255)
  365. schema.x11.LemonChiffon4 = color(138,136,112,255)
  366. schema.x11.LightBlue1 = color(191,238,255,255)
  367. schema.x11.LightBlue2 = color(177,223,237,255)
  368. schema.x11.LightBlue3 = color(154,191,205,255)
  369. schema.x11.LightBlue4 = color(104,130,138,255)
  370. schema.x11.LightCyan1 = color(224,255,255,255)
  371. schema.x11.LightCyan2 = color(209,237,237,255)
  372. schema.x11.LightCyan3 = color(179,205,205,255)
  373. schema.x11.LightCyan4 = color(122,138,138,255)
  374. schema.x11.LightGoldenrod1 = color(255,235,138,255)
  375. schema.x11.LightGoldenrod2 = color(237,220,130,255)
  376. schema.x11.LightGoldenrod3 = color(205,189,112,255)
  377. schema.x11.LightGoldenrod4 = color(138,128,75,255)
  378. schema.x11.LightPink1 = color(255,174,184,255)
  379. schema.x11.LightPink2 = color(237,161,173,255)
  380. schema.x11.LightPink3 = color(205,140,149,255)
  381. schema.x11.LightPink4 = color(138,94,100,255)
  382. schema.x11.LightSalmon1 = color(255,160,122,255)
  383. schema.x11.LightSalmon2 = color(237,149,114,255)
  384. schema.x11.LightSalmon3 = color(205,128,98,255)
  385. schema.x11.LightSalmon4 = color(138,86,66,255)
  386. schema.x11.LightSkyBlue1 = color(175,226,255,255)
  387. schema.x11.LightSkyBlue2 = color(164,211,237,255)
  388. schema.x11.LightSkyBlue3 = color(140,181,205,255)
  389. schema.x11.LightSkyBlue4 = color(95,123,138,255)
  390. schema.x11.LightSteelBlue1 = color(201,225,255,255)
  391. schema.x11.LightSteelBlue2 = color(187,210,237,255)
  392. schema.x11.LightSteelBlue3 = color(161,181,205,255)
  393. schema.x11.LightSteelBlue4 = color(109,123,138,255)
  394. schema.x11.LightYellow1 = color(255,255,224,255)
  395. schema.x11.LightYellow2 = color(237,237,209,255)
  396. schema.x11.LightYellow3 = color(205,205,179,255)
  397. schema.x11.LightYellow4 = color(138,138,122,255)
  398. schema.x11.Magenta1 = color(255,0,255,255)
  399. schema.x11.Magenta2 = color(237,0,237,255)
  400. schema.x11.Magenta3 = color(205,0,205,255)
  401. schema.x11.Magenta4 = color(138,0,138,255)
  402. schema.x11.Maroon1 = color(255,52,178,255)
  403. schema.x11.Maroon2 = color(237,48,167,255)
  404. schema.x11.Maroon3 = color(205,40,144,255)
  405. schema.x11.Maroon4 = color(138,28,98,255)
  406. schema.x11.MediumOrchid1 = color(224,102,255,255)
  407. schema.x11.MediumOrchid2 = color(209,94,237,255)
  408. schema.x11.MediumOrchid3 = color(179,81,205,255)
  409. schema.x11.MediumOrchid4 = color(122,54,138,255)
  410. schema.x11.MediumPurple1 = color(170,130,255,255)
  411. schema.x11.MediumPurple2 = color(159,121,237,255)
  412. schema.x11.MediumPurple3 = color(136,104,205,255)
  413. schema.x11.MediumPurple4 = color(93,71,138,255)
  414. schema.x11.MistyRose1 = color(255,227,225,255)
  415. schema.x11.MistyRose2 = color(237,212,210,255)
  416. schema.x11.MistyRose3 = color(205,182,181,255)
  417. schema.x11.MistyRose4 = color(138,124,123,255)
  418. schema.x11.NavajoWhite1 = color(255,221,173,255)
  419. schema.x11.NavajoWhite2 = color(237,206,160,255)
  420. schema.x11.NavajoWhite3 = color(205,178,138,255)
  421. schema.x11.NavajoWhite4 = color(138,121,94,255)
  422. schema.x11.OliveDrab1 = color(191,255,62,255)
  423. schema.x11.OliveDrab2 = color(178,237,58,255)
  424. schema.x11.OliveDrab3 = color(154,205,49,255)
  425. schema.x11.OliveDrab4 = color(104,138,33,255)
  426. schema.x11.Orange1 = color(255,165,0,255)
  427. schema.x11.Orange2 = color(237,154,0,255)
  428. schema.x11.Orange3 = color(205,132,0,255)
  429. schema.x11.Orange4 = color(138,89,0,255)
  430. schema.x11.OrangeRed1 = color(255,68,0,255)
  431. schema.x11.OrangeRed2 = color(237,63,0,255)
  432. schema.x11.OrangeRed3 = color(205,54,0,255)
  433. schema.x11.OrangeRed4 = color(138,36,0,255)
  434. schema.x11.Orchid1 = color(255,130,249,255)
  435. schema.x11.Orchid2 = color(237,122,232,255)
  436. schema.x11.Orchid3 = color(205,104,201,255)
  437. schema.x11.Orchid4 = color(138,71,136,255)
  438. schema.x11.PaleGreen1 = color(154,255,154,255)
  439. schema.x11.PaleGreen2 = color(144,237,144,255)
  440. schema.x11.PaleGreen3 = color(124,205,124,255)
  441. schema.x11.PaleGreen4 = color(84,138,84,255)
  442. schema.x11.PaleTurquoise1 = color(186,255,255,255)
  443. schema.x11.PaleTurquoise2 = color(174,237,237,255)
  444. schema.x11.PaleTurquoise3 = color(150,205,205,255)
  445. schema.x11.PaleTurquoise4 = color(102,138,138,255)
  446. schema.x11.PaleVioletRed1 = color(255,130,170,255)
  447. schema.x11.PaleVioletRed2 = color(237,121,159,255)
  448. schema.x11.PaleVioletRed3 = color(205,104,136,255)
  449. schema.x11.PaleVioletRed4 = color(138,71,93,255)
  450. schema.x11.PeachPuff1 = color(255,218,184,255)
  451. schema.x11.PeachPuff2 = color(237,202,173,255)
  452. schema.x11.PeachPuff3 = color(205,175,149,255)
  453. schema.x11.PeachPuff4 = color(138,119,100,255)
  454. schema.x11.Pink1 = color(255,181,196,255)
  455. schema.x11.Pink2 = color(237,169,183,255)
  456. schema.x11.Pink3 = color(205,145,158,255)
  457. schema.x11.Pink4 = color(138,99,108,255)
  458. schema.x11.Plum1 = color(255,186,255,255)
  459. schema.x11.Plum2 = color(237,174,237,255)
  460. schema.x11.Plum3 = color(205,150,205,255)
  461. schema.x11.Plum4 = color(138,102,138,255)
  462. schema.x11.Purple1 = color(155,48,255,255)
  463. schema.x11.Purple2 = color(145,43,237,255)
  464. schema.x11.Purple3 = color(124,38,205,255)
  465. schema.x11.Purple4 = color(84,25,138,255)
  466. schema.x11.Red1 = color(255,0,0,255)
  467. schema.x11.Red2 = color(237,0,0,255)
  468. schema.x11.Red3 = color(205,0,0,255)
  469. schema.x11.Red4 = color(138,0,0,255)
  470. schema.x11.RosyBrown1 = color(255,192,192,255)
  471. schema.x11.RosyBrown2 = color(237,179,179,255)
  472. schema.x11.RosyBrown3 = color(205,155,155,255)
  473. schema.x11.RosyBrown4 = color(138,104,104,255)
  474. schema.x11.RoyalBlue1 = color(72,118,255,255)
  475. schema.x11.RoyalBlue2 = color(67,109,237,255)
  476. schema.x11.RoyalBlue3 = color(58,94,205,255)
  477. schema.x11.RoyalBlue4 = color(38,63,138,255)
  478. schema.x11.Salmon1 = color(255,140,104,255)
  479. schema.x11.Salmon2 = color(237,130,98,255)
  480. schema.x11.Salmon3 = color(205,112,84,255)
  481. schema.x11.Salmon4 = color(138,75,57,255)
  482. schema.x11.SeaGreen1 = color(84,255,159,255)
  483. schema.x11.SeaGreen2 = color(77,237,147,255)
  484. schema.x11.SeaGreen3 = color(67,205,127,255)
  485. schema.x11.SeaGreen4 = color(45,138,86,255)
  486. schema.x11.Seashell1 = color(255,244,237,255)
  487. schema.x11.Seashell2 = color(237,228,221,255)
  488. schema.x11.Seashell3 = color(205,196,191,255)
  489. schema.x11.Seashell4 = color(138,133,130,255)
  490. schema.x11.Sienna1 = color(255,130,71,255)
  491. schema.x11.Sienna2 = color(237,121,66,255)
  492. schema.x11.Sienna3 = color(205,104,57,255)
  493. schema.x11.Sienna4 = color(138,71,38,255)
  494. schema.x11.SkyBlue1 = color(135,206,255,255)
  495. schema.x11.SkyBlue2 = color(125,191,237,255)
  496. schema.x11.SkyBlue3 = color(108,165,205,255)
  497. schema.x11.SkyBlue4 = color(73,112,138,255)
  498. schema.x11.SlateBlue1 = color(130,110,255,255)
  499. schema.x11.SlateBlue2 = color(122,103,237,255)
  500. schema.x11.SlateBlue3 = color(104,89,205,255)
  501. schema.x11.SlateBlue4 = color(71,59,138,255)
  502. schema.x11.SlateGray1 = color(197,226,255,255)
  503. schema.x11.SlateGray2 = color(184,211,237,255)
  504. schema.x11.SlateGray3 = color(159,181,205,255)
  505. schema.x11.SlateGray4 = color(108,123,138,255)
  506. schema.x11.Snow1 = color(255,249,249,255)
  507. schema.x11.Snow2 = color(237,232,232,255)
  508. schema.x11.Snow3 = color(205,201,201,255)
  509. schema.x11.Snow4 = color(138,136,136,255)
  510. schema.x11.SpringGreen1 = color(0,255,126,255)
  511. schema.x11.SpringGreen2 = color(0,237,118,255)
  512. schema.x11.SpringGreen3 = color(0,205,102,255)
  513. schema.x11.SpringGreen4 = color(0,138,68,255)
  514. schema.x11.SteelBlue1 = color(99,183,255,255)
  515. schema.x11.SteelBlue2 = color(91,172,237,255)
  516. schema.x11.SteelBlue3 = color(79,147,205,255)
  517. schema.x11.SteelBlue4 = color(53,99,138,255)
  518. schema.x11.Tan1 = color(255,165,79,255)
  519. schema.x11.Tan2 = color(237,154,73,255)
  520. schema.x11.Tan3 = color(205,132,63,255)
  521. schema.x11.Tan4 = color(138,89,43,255)
  522. schema.x11.Thistle1 = color(255,225,255,255)
  523. schema.x11.Thistle2 = color(237,210,237,255)
  524. schema.x11.Thistle3 = color(205,181,205,255)
  525. schema.x11.Thistle4 = color(138,123,138,255)
  526. schema.x11.Tomato1 = color(255,99,71,255)
  527. schema.x11.Tomato2 = color(237,91,66,255)
  528. schema.x11.Tomato3 = color(205,79,57,255)
  529. schema.x11.Tomato4 = color(138,53,38,255)
  530. schema.x11.Turquoise1 = color(0,244,255,255)
  531. schema.x11.Turquoise2 = color(0,228,237,255)
  532. schema.x11.Turquoise3 = color(0,196,205,255)
  533. schema.x11.Turquoise4 = color(0,133,138,255)
  534. schema.x11.VioletRed1 = color(255,62,150,255)
  535. schema.x11.VioletRed2 = color(237,58,140,255)
  536. schema.x11.VioletRed3 = color(205,49,119,255)
  537. schema.x11.VioletRed4 = color(138,33,81,255)
  538. schema.x11.Wheat1 = color(255,230,186,255)
  539. schema.x11.Wheat2 = color(237,216,174,255)
  540. schema.x11.Wheat3 = color(205,186,150,255)
  541. schema.x11.Wheat4 = color(138,125,102,255)
  542. schema.x11.Yellow1 = color(255,255,0,255)
  543. schema.x11.Yellow2 = color(237,237,0,255)
  544. schema.x11.Yellow3 = color(205,205,0,255)
  545. schema.x11.Yellow4 = color(138,138,0,255)
  546. schema.x11.Gray0 = color(189,189,189,255)
  547. schema.x11.Green0 = color(0,255,0,255)
  548. schema.x11.Grey0 = color(189,189,189,255)
  549. schema.x11.Maroon0 = color(175,48,95,255)
  550. schema.x11.Purple0 = color(160,31,239,255)
  551.  
  552. for a, b in pairs(schema.x11) do
  553. colors["x11-" .. string.lower(a)] = b
  554. end
  555.  
  556. -- Generator
  557.  
  558. local domains = {
  559. { -- The default color
  560. d = "", -- Subdomain
  561. w = true, -- Grayscale generate subdomains?
  562. c = function(b) return b end -- Returns color
  563. },
  564. {
  565. d = "slightly-dark-",
  566. w = false,
  567. c = function(b) return b:mix(color(65, 255), 0.5) end
  568. },
  569. {
  570. d = "dark-",
  571. w = false,
  572. c = function(b) return b:mix(color(0, 255), 0.5) end
  573. },
  574. {
  575. d = "slightly-light-",
  576. w = false,
  577. c = function(b) return b:mix(color(190, 255), 0.5) end
  578. },
  579. {
  580. d = "light-",
  581. w = false,
  582. c = function(b) return b:mix(color(255, 255), 0.5) end
  583. },
  584. {
  585. d = "middle-",
  586. w = false,
  587. c = function(b) return b:mix(color(127, 255), 0.5) end
  588. },
  589. {
  590. d = "reddish-",
  591. w = true,
  592. c = function(b) return b:mix(color(255, 0, 0, 255), 0.6) end
  593. },
  594. {
  595. d = "greenish-",
  596. w = true,
  597. c = function(b) return b:mix(color(0, 255, 0, 255), 0.6) end
  598. },
  599. {
  600. d = "blueish-",
  601. w = true,
  602. c = function(b) return b:mix(color(0, 0, 255, 255), 0.6) end
  603. },
  604. {
  605. d = "cyanish-",
  606. w = true,
  607. c = function(b) return b:mix(color(0, 255, 255, 255), 0.6) end
  608. },
  609. {
  610. d = "magentish-",
  611. w = true,
  612. c = function(b) return b:mix(color(255, 0, 255, 255), 0.6) end
  613. },
  614. {
  615. d = "yellowish-",
  616. w = true,
  617. c = function(b) return b:mix(color(255, 255, 0, 255), 0.6) end
  618. },
  619. {
  620. d = "slightly-reddish-",
  621. w = true,
  622. c = function(b) return b:mix(color(255, 0, 0, 255), 0.7) end
  623. },
  624. {
  625. d = "slightly-greenish-",
  626. w = true,
  627. c = function(b) return b:mix(color(0, 255, 0, 255), 0.7) end
  628. },
  629. {
  630. d = "slightly-blueish-",
  631. w = true,
  632. c = function(b) return b:mix(color(0, 0, 255, 255), 0.7) end
  633. },
  634. {
  635. d = "reduced-",
  636. w = false,
  637. c = function(b) return color(math.max(b.r-90,0), math.max(b.g-90,0), math.max(b.b-90,0), 255) end
  638. },
  639. {
  640. d = "saturated-",
  641. w = false,
  642. c = function(b) return color(b.r*b.r/255, b.g*b.g/255, b.b*b.b/255) end
  643. },
  644. {
  645. d = "over-saturated-",
  646. w = false,
  647. c = function(b) return color(b.r*b.r*b.r/65025, b.g*b.g*b.g/65025, b.b*b.b*b.b/65025) end
  648. },
  649. }
  650.  
  651. -- Generate subdomains.
  652. for a, b in pairs(colors1) do
  653. for c, d in ipairs (domains) do
  654. colors[d.d .. a] = d.c(b)
  655. end
  656.  
  657.  
  658. for i = 1, 9 do
  659. colors[a .. "-" .. i .. "0"] = b:mix(color(0, 255), i/10)
  660. end
  661. end
  662.  
  663. -- Grayscale
  664. for a, b in ipairs (domains) do
  665. if b.w then
  666. colors[b.d .. "white"] = b.c(color(255, 255))
  667. colors[b.d .. "black"] = b.c(color(0, 255))
  668. colors[b.d .. "grey"] = b.c(color(128, 255))
  669. colors[b.d .. "gray"] = b.c(color(128, 255))
  670.  
  671. for i = 1, 9 do
  672. colors[b.d .. "white-" .. i .. "0"] = b.c(color(25.5 * i, 255))
  673. end
  674. end
  675. end
  676. end
  677.  
  678. -- Initialise
  679.  
  680. --[[
  681.  
  682. Hex() -> Color() -> color()
  683.  
  684. ]]
  685.  
  686. Hex = function(l, alpha)
  687. if not (type(l) == "string") then
  688. assert(false, "bad argument #1 to 'Hex' (string expected, got ".. type(l) ..")")
  689. end
  690.  
  691. if #l == 6 then
  692. return Color(tonumber(l, 16))
  693. elseif #l == 3 then
  694. l = string.rep(string.sub(l, 1, 1), 2) +
  695. string.rep(string.sub(l, 2, 2), 2) +
  696. string.rep(string.sub(l, 3, 3), 2)
  697. elseif #l == 2 then
  698. l = string.rep(l, 3)
  699. elseif #l == 1 then
  700. l = string.rep(l, 6)
  701. end
  702.  
  703. return Color(tonumber(l, 16), alpha)
  704. end
  705.  
  706. --[[
  707.  
  708. Hue() -> color()
  709.  
  710. ]]
  711.  
  712. Hue = function(val, alpha)
  713. local r, g, b = 0, 0, 0
  714.  
  715. if val > 360 then
  716. val = val - math.floor(val / 360) * 360
  717. elseif val < 0 then
  718. val = val + math.floor(val / 360) * 360
  719. end
  720.  
  721. val = math.floor(val)
  722.  
  723. if val <= 60 then
  724. r = 255
  725. g = (val/60)*255
  726. b = 0
  727. elseif val <= 120 then
  728. r = 255 - (val-60)/60 * 255
  729. g = 255
  730. b = 0
  731. elseif val <= 180 then
  732. r = 0
  733. g = 255
  734. b = ((val-120)/60)*255
  735. elseif val <= 240 then
  736. r = 0
  737. g = 255 - (val-180)/60 * 255
  738. b = 255
  739. elseif val <= 300 then
  740. r = ((val-240)/60)*255
  741. g = 0
  742. b = 255
  743. else
  744. r = 255
  745. g = 0
  746. b = 255 - (val-300)/60 * 255
  747. end
  748.  
  749. return color(r, g, b, alpha or 255)
  750. end
  751.  
  752. --[[
  753.  
  754. Color(col, alpha) -> ... -> color()
  755.  
  756. ]]
  757.  
  758. Color = function(s, alpha)
  759. local c = color(0, 255)
  760.  
  761. -- Define Color
  762. if type(s) == "string" then
  763. s = string.lower(s)
  764. if s == "random" then
  765. c = RandomColor()
  766. elseif s == "transparent" then
  767. return color(0, 0)
  768. elseif (s == "random-grey") or (s == "random-gray") then
  769. c = color(math.random(255))
  770. elseif string.sub(s, 1, 4) == "hue-" then
  771. c = Hue(tonumber(string.sub(s, 5, #s)), a)
  772. elseif colors[s] then
  773. c = colors[s]
  774. elseif string.sub(s, 1, 1) == "#" and #s > 1 then
  775. c = Hex(string.sub(s, 2, #s), alpha)
  776. end
  777. elseif type(s) == "table" then
  778. local methods = {
  779. {
  780. name = "origin",
  781. f = function(q)
  782. return Color(q)
  783. end
  784. },
  785. {
  786. name = "shade",
  787. f = function(q)
  788. for a, b in pairs{
  789. -- Visibility
  790. ["light"] = function()
  791. return c:mix(color(255, 255), 0.5)
  792. end,
  793. ["dark"] = function()
  794. return c:mix(color(0, 255), 0.5)
  795. end,
  796. ["slightly-dark"] = function()
  797. return c:mix(color(65, 255), 0.5)
  798. end,
  799. ["slightly-light"] = function()
  800. return c:mix(color(190, 255), 0.5)
  801. end,
  802. ["middle"] = function()
  803. return c:mix(color(127, 255), 0.5)
  804. end,
  805. ["saturated"] = function()
  806. return color(c.r*c.r/255, c.g*c.g/255, c.b*c.b/255)
  807. end,
  808.  
  809. -- Shading
  810. ["reddish"] = function()
  811. return c:mix(color(255, 0, 0), 0.6)
  812. end,
  813. ["greenish"] = function()
  814. return c:mix(color(0, 255, 0), 0.6)
  815. end,
  816. ["blueish"] = function()
  817. return c:mix(color(0, 0, 255), 0.6)
  818. end,
  819. ["slightly-reddish"] = function()
  820. return c:mix(color(255, 0, 0), 0.7)
  821. end,
  822. ["slightly-greenish"] = function()
  823. return c:mix(color(0, 255, 0), 0.7)
  824. end,
  825. ["slightly-blueish"] = function()
  826. return c:mix(color(0, 0, 255), 0.7)
  827. end,
  828. } do
  829. if q == a then
  830. return b()
  831. end
  832. end
  833.  
  834. end
  835. },
  836. {
  837. name = "desaturate",
  838. f = function(q)
  839. for a, b in pairs{
  840. ["avg"] = function()
  841. return color((c.r+c.g+c.b)/3, 255)
  842. end,
  843. ["hsv"] = function()
  844. return color(math.max(c.r, c.g, c.b), 255)
  845. end,
  846. ["hsl"] = function()
  847. return color((math.max(c.r, c.g, c.b) + math.min(c.r, c.g, c.b))*.5, 255)
  848. end,
  849. ["lum"] = function()
  850. return color(c.r*.22 + c.g*.72 + c.b*.06, 255)
  851. end,
  852. ["red"] = function()
  853. return color(c.r, 255)
  854. end,
  855. ["green"] = function()
  856. return color(c.g, 255)
  857. end,
  858. ["blue"] = function()
  859. return color(c.b, 255)
  860. end,
  861. } do
  862. if q == a then
  863. return b()
  864. end
  865. end
  866. end
  867. },
  868. {
  869. name = "invert",
  870. f = function(q)
  871. if q then
  872. return color(255-c.r, 255-c.g, 255-c.b, 255)
  873. end
  874. end
  875. },
  876. {
  877. name = "filter",
  878. f = function(q)
  879. local m = c
  880. if q.r == false then
  881. m.r = 0
  882. end if q.g == false then
  883. m.g = 0
  884. end if q.b == false then
  885. m.b = 0
  886. end
  887. return m
  888. end
  889. },
  890. {
  891. name = "alpha",
  892. f = function(q)
  893. return color(c.r, c.g, c.b, q)
  894. end
  895. },
  896. }
  897.  
  898. for d, e in ipairs(methods) do
  899. for a, b in pairs(s) do
  900. if a == e.name then
  901. c = e.f(b) or c
  902. end
  903. end
  904. end
  905. elseif type(s) == "number" then
  906. local b = s%256
  907. local g = ((s - b)/256)%256
  908. local r = ((s - g - b)/256^2)
  909.  
  910. c = color(r, g, b)
  911. elseif type(s) == "userdata" then -- s is already a color
  912. c = s
  913. elseif type(s) == "nil" then
  914. --if s then
  915. return RandomColor()
  916. --end
  917. else
  918. assert(false, "bad argument #1 to 'Color' (string expected, got ".. type(s) ..")")
  919. end
  920.  
  921. -- Set transparency
  922. if type(alpha) == "number" then
  923. c.a = alpha
  924. elseif type(alpha) == "string" then
  925. local m = {
  926. ["slightly-opaque"] = 225,
  927. ["slightly-visible"] = 50
  928. }
  929. c.a = m[alpha]
  930. elseif type(alpha) == "boolean" then
  931. if alpha then
  932. c.a = 255
  933. else
  934. c.a = 0
  935. end
  936. elseif type(s) == "table" then
  937. elseif alpha == nil then
  938. -- ignore
  939. else
  940. assert(false, "bad argument #2 to 'Color' (number expected, got ".. type(alpha) ..")")
  941. end
  942.  
  943. return c
  944. end
  945.  
  946. --[[
  947.  
  948. Colors(col1, col2, mode) -> color()
  949.  
  950. ]]
  951.  
  952. Colors = function(c1, c2, mode)
  953. local modes = {
  954. ["dif"] = function()
  955. return color(math.abs(c1.r-c2.r), math.abs(c1.g-c2.g), math.abs(c1.b-c2.b))
  956. end,
  957. ["avg"] = function()
  958. return color((c1.r+c2.r)/2, (c1.g+c2.g)/2, (c1.b+c2.b)/2)
  959. end,
  960. ["min"] = function()
  961. return color(math.min(c1.r, c2.r), math.min(c1.g, c2.g), math.min(c1.b, c2.b))
  962. end,
  963. ["max"] = function()
  964. return color(math.max(c1.r, c2.r), math.max(c1.g, c2.g), math.max(c1.b, c2.b))
  965. end,
  966. ["sqrt"] = function()
  967. return color(math.sqrt(c1.r^2 + c2.r^2)/math.sqrt(2),
  968. math.sqrt(c1.g^2 + c2.g^2)/math.sqrt(2),
  969. math.sqrt(c1.b^2 + c2.b^2)/math.sqrt(2)
  970. )
  971. end,
  972. ["multiply"] = function()
  973. return color(c1.r*c2.r/255, c1.g*c2.g/255, c1.b*c2.b/255)
  974. end,
  975. ["screen"] = function()
  976. return color(255-(255-c1.r)*(255-c2.r)/255,
  977. 255-(255-c1.g)*(255-c2.g)/255,
  978. 255-(255-c1.b)*(255-c2.b)/255
  979. )
  980. end,
  981. }
  982.  
  983. return modes[string.lower(mode)]()
  984. end
  985.  
  986. -- Fast access implementations
  987.  
  988. Fill = function(s, a) fill(Color(s, a)) end
  989. Stroke = function(s, a) stroke(Color(s, a)) end
  990. Tint = function(s, a) tint(Color(s, a)) end
  991. Background = function(s, a) background(Color(s, a)) end
  992. RandomColor = function(a) return color(math.random(255), math.random(255), math.random(255), a or 255) end
  993.  
  994.  
  995. --# Main
  996. -- colors1
  997.  
  998. function setup()
  999. displayMode(FULLSCREEN)
  1000. genIcon()
  1001.  
  1002. parameter.action("Clear Data", function() clearLocalData() sizeChanged() end)
  1003.  
  1004. startMessage = "Tap a color to see it's details"
  1005. selectedColor = startMessage
  1006. latestTouch = vec2(WIDTH*.5, HEIGHT*.5)
  1007. sizeChanged()
  1008. end
  1009.  
  1010. function sizeChanged(w, h)
  1011. local min = math.min(WIDTH, HEIGHT)
  1012. colorBullets = {}
  1013.  
  1014. local function width(i, radius)
  1015. return WIDTH*.5 + math.cos(i*math.pi/180) * radius
  1016. end
  1017.  
  1018. local function height(i, radius)
  1019. return HEIGHT*.5 + math.sin(i*math.pi/180) * radius
  1020. end
  1021.  
  1022. local function add(degree, radius, col)
  1023. table.insert(colorBullets, ColorBullet(width(degree, radius), height(degree, radius), col))
  1024. end
  1025.  
  1026. -- Hue
  1027. for i = 0, 360 do
  1028. add(i, min*.5-20, "hue-" .. i)
  1029. end
  1030.  
  1031. -- All other colors
  1032. local v = {}
  1033. for a, b in pairs(colors) do
  1034. table.insert(v, {a, b})
  1035. end
  1036.  
  1037. table.sort(v, function(a, b) return a[1] < b[1] end)
  1038. for a, b in ipairs(v) do
  1039. if a > 360 * 3 then
  1040. add(3*a-360*3, min*.5-40 - math.floor((3*a-360*3+1)/360)*20, b[1])
  1041. else
  1042. add(2*a, min*.5-40 - math.floor((2*a+1)/360)*20, b[1])
  1043. end
  1044. end
  1045.  
  1046. placeholders = {}
  1047. for i = 1, 15 do
  1048. table.insert(placeholders, Placeholder(WIDTH-25, HEIGHT-50*i+25, i .. "r"))
  1049. table.insert(placeholders, Placeholder(WIDTH-75, HEIGHT-50*i+25, i .. "l"))
  1050. end
  1051. end
  1052.  
  1053. function genIcon()
  1054. local m = image(320, 320)
  1055. setContext(m)
  1056. -- Background and Circle
  1057. Background(0)
  1058. for i = 1, 360 do
  1059. Fill(Hue(i))
  1060. ellipse(160 + math.cos(i*math.pi/180) * 140, 160 + math.sin(i*math.pi/180) * 140, 15)
  1061. end
  1062.  
  1063. -- Text
  1064. fontSize(80)
  1065. font("MarkerFelt-Thin")
  1066.  
  1067. local w = {
  1068. {
  1069. l = "C",
  1070. c = "darkviolet"
  1071. },
  1072. {
  1073. l = "o",
  1074. c = "red"
  1075. },
  1076. {
  1077. l = "l",
  1078. c = "neon-green"
  1079. },
  1080. {
  1081. l = "o",
  1082. c = "pink"
  1083. },
  1084. {
  1085. l = "r",
  1086. c = "skyblue"
  1087. },
  1088. {
  1089. l = "s",
  1090. c = "forestgreen"
  1091. },
  1092. }
  1093.  
  1094. local p = ""
  1095. for a, b in ipairs(w) do p = p .. b.l end
  1096. local q, _ = textSize(p)
  1097.  
  1098. local n = 0
  1099. for a, b in ipairs(w) do
  1100. local n1, _ = textSize(b.l)
  1101.  
  1102. Fill(b.c)
  1103. text(b.l, 160 - q*.5 + n + n1*.5, 160)
  1104. n = n + n1
  1105. end
  1106.  
  1107. -- Version
  1108. Fill("white-80")
  1109. font("Futura-Medium")
  1110. fontSize(40)
  1111. text("v7", 290, 290)
  1112.  
  1113. -- Exit
  1114. setContext()
  1115. saveImage("Project:Icon", m)
  1116. end
  1117.  
  1118. function draw()
  1119. Background("black")
  1120. resetStyle()
  1121.  
  1122. -- Logo
  1123. sprite("Project:Icon", WIDTH*.5, HEIGHT*.5 + 64, 128)
  1124.  
  1125. -- Selected Color
  1126. Fill("white-80")
  1127. font("ArialRoundedMTBold")
  1128. fontSize(20)
  1129. text(selectedColor, WIDTH*.5, HEIGHT*.5-20)
  1130.  
  1131. for a, b in ipairs(colorBullets) do
  1132. b:draw()
  1133. end
  1134. for a, b in ipairs(placeholders) do
  1135. b:draw()
  1136. end
  1137.  
  1138. -- Latest Touch
  1139. resetStyle()
  1140. Fill("transparent")
  1141. strokeWidth(5-((ElapsedTime*60)%70)/70*5)
  1142. Stroke("white", 255-((ElapsedTime*60)%70)/70*255)
  1143. ellipse(latestTouch.x, latestTouch.y, 20+(ElapsedTime*60)%70)
  1144. fill(math.sin(ElapsedTime*6)*255, 255)
  1145. strokeWidth(0)
  1146. ellipse(latestTouch.x, latestTouch.y, 5)
  1147. end
  1148.  
  1149. function touched(t)
  1150. for a, b in ipairs(placeholders) do
  1151. b:touched(t)
  1152. end
  1153.  
  1154. selectedColor = "No Color"
  1155. latestTouch = vec2(t.pos.x, t.pos.y)
  1156. for a, b in ipairs(colorBullets) do
  1157. b:touched(t)
  1158. end
  1159. end
  1160.  
  1161.  
  1162. ColorBullet = class()
  1163.  
  1164. function ColorBullet:init(x, y, col)
  1165. self.pos = vec2(x, y)
  1166. self.color = col
  1167. end
  1168.  
  1169. function ColorBullet:draw()
  1170. strokeWidth(0)
  1171. Fill(self.color)
  1172. ellipse(self.pos.x, self.pos.y, 15)
  1173. end
  1174.  
  1175. function ColorBullet:touched(t)
  1176. if self:isTouched(t) then
  1177. selectedColor = self.color
  1178. end
  1179. end
  1180.  
  1181. function ColorBullet:isTouched(t)
  1182. if (self.pos.x - t.pos.x)^2 + (self.pos.y - t.pos.y)^2 < 10^2 then
  1183. return true
  1184. end
  1185. return false
  1186. end
  1187.  
  1188. Placeholder = class()
  1189.  
  1190. function Placeholder:init(x, y, id)
  1191. self.pos = vec2(x, y)
  1192. self.id = id
  1193. self.color = ""
  1194.  
  1195. local c = readLocalData("col_" .. self.id)
  1196.  
  1197. if c then
  1198. self.color = c
  1199. else
  1200. self.color = "white-30"
  1201. end
  1202. end
  1203.  
  1204. function Placeholder:draw()
  1205. strokeWidth(0)
  1206. Fill(self.color)
  1207. ellipse(self.pos.x, self.pos.y, 35)
  1208. end
  1209.  
  1210. function Placeholder:touched(t)
  1211. if t.state ~= BEGAN then
  1212. return
  1213. end
  1214.  
  1215. if self:isTouched(t) and selectedColor ~= "No Color" and selectedColor ~= startMessage then
  1216. local k = Color(selectedColor)
  1217. self.color = selectedColor
  1218. saveLocalData("col_" .. self.id, self.color)
  1219. elseif self:isTouched(t) then
  1220. alert("The color you selected is Color('" .. self.color .. "')", "Color")
  1221. end
  1222. end
  1223.  
  1224. function Placeholder:isTouched(t)
  1225. if (self.pos.x - t.pos.x)^2 + (self.pos.y - t.pos.y)^2 < 30^2 then
  1226. return true
  1227. end
  1228. return false
  1229. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement