NeOzay

color

Aug 4th, 2021 (edited)
48
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local colors = require("colors")
  2.  
  3.  
  4. ---@class Colors
  5. ---@field white color
  6. ---@field orange color
  7. ---@field magenta color
  8. ---@field lightblue color
  9. ---@field yellow color
  10. ---@field lime color
  11. ---@field pink color
  12. ---@field gray color
  13. ---@field silver color
  14. ---@field cyan color
  15. ---@field purple color
  16. ---@field blue color
  17. ---@field brown color
  18. ---@field green color
  19. ---@field red color
  20. ---@field black color
  21. ---@overload fun(cl:number):color
  22. ---@overload fun(cl:string):color
  23. ---@overload fun(cl:number,isPaletteIndex:boolean):color
  24. local Colors = {}
  25.  
  26. ---@param cl number
  27. ---@param isPaletteIndex boolean
  28. ---@overload fun(cl:number):color
  29. ---@overload fun(cl:string):color
  30. function Colors.__index(cl, isPaletteIndex)
  31.     ---@class color
  32.     ---@field color number
  33.     ---@field isPaletteIndex boolean
  34.     local o = {}
  35.     if type(cl) == "string" then
  36.         o.color = colors[cl]
  37.         o.isPaletteIndex = true
  38.     else
  39.         o.color = cl
  40.         o.isPaletteIndex = isPaletteIndex or false
  41.     end
  42.     return o
  43. end
  44.  
  45. setmetatable(Colors,Colors)
  46.  
  47. Colors.white = Colors(0xFFFFFF)
  48. Colors.orange = Colors(0xFFCC33)
  49. Colors.magenta = Colors(0xCC66CC)
  50. Colors.lightblue = Colors(0x6699FF)
  51. Colors.yellow = Colors(0xFFFF33)
  52. Colors.lime = Colors(0x33CC33)
  53. Colors.pink = Colors(0xFF6699)
  54. Colors.gray = Colors(0x333333)
  55. Colors.silver = Colors(0xCCCCCC)
  56. Colors.cyan = Colors(0x336699)
  57. Colors.purple = Colors(0x9933CC)
  58. Colors.blue = Colors(0x333399)
  59. Colors.brown = Colors(0x663300)
  60. Colors.green = Colors(0x336600)
  61. Colors.red = Colors(0xFF3333)
  62. Colors.black = Colors(0x0)
  63.  
  64. return Colors
  65.  
  66.  
  67.  
RAW Paste Data