colors.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. COLORS
  3. Here's a little bootstrapping to create our global Color constants.
  4. At first it seemed like overkill, but then as the solvers and inspectors
  5. moved forward having these objects available became highly desirable.
  6. Sure, ES5 doesn't really have constants but the all-caps alerts you
  7. to the fact that them thar variables ought not to be messed with.
  8. */
  9. export function Color( name, initial, hex, styleF, styleB ){
  10. this.name = name
  11. this.initial = initial
  12. this.hex = hex
  13. this.styleF = styleF
  14. this.styleB = styleB
  15. }
  16. // Global constants to describe sticker colors.
  17. globalThis.W = globalThis.WHITE = new Color(
  18. 'white',
  19. 'W',
  20. '#FFF',
  21. 'font-weight: bold; color: #888',
  22. 'background-color: #F3F3F3; color: rgba( 0, 0, 0, 0.5 )'
  23. )
  24. globalThis.O = globalThis.ORANGE = new Color(
  25. 'orange',
  26. 'O',
  27. '#F60',
  28. 'font-weight: bold; color: #F60',
  29. 'background-color: #F60; color: rgba( 255, 255, 255, 0.9 )'
  30. )
  31. globalThis.B = globalThis.BLUE = new Color(
  32. 'blue',
  33. 'B',
  34. '#00D',
  35. 'font-weight: bold; color: #00D',
  36. 'background-color: #00D; color: rgba( 255, 255, 255, 0.9 )'
  37. )
  38. globalThis.R = globalThis.RED = new Color(
  39. 'red',
  40. 'R',
  41. '#F00',
  42. 'font-weight: bold; color: #F00',
  43. 'background-color: #F00; color: rgba( 255, 255, 255, 0.9 )'
  44. )
  45. globalThis.G = globalThis.GREEN = new Color(
  46. 'green',
  47. 'G',
  48. '#0A0',
  49. 'font-weight: bold; color: #0A0',
  50. 'background-color: #0A0; color: rgba( 255, 255, 255, 0.9 )'
  51. )
  52. globalThis.Y = globalThis.YELLOW = new Color(
  53. 'yellow',
  54. 'Y',
  55. '#FE0',
  56. 'font-weight: bold; color: #ED0',
  57. 'background-color: #FE0; color: rgba( 0, 0, 0, 0.5 )'
  58. )
  59. globalThis.COLORLESS = new Color(
  60. 'NA',
  61. 'X',
  62. '#DDD',
  63. 'color: #EEE',
  64. 'color: #DDD'
  65. )