vis.js is a dynamic, browser-based visualization library
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.

552 lines
20 KiB

  1. let Hammer = require('../module/hammer');
  2. let hammerUtil = require('../hammerUtil');
  3. let util = require('../util');
  4. class ColorPicker {
  5. constructor(pixelRatio = 1) {
  6. this.pixelRatio = pixelRatio;
  7. this.generated = false;
  8. this.centerCoordinates = {x:289/2, y:289/2};
  9. this.r = 289 * 0.49;
  10. this.color = {r:255,g:255,b:255,a:1.0};
  11. this.hueCircle = undefined;
  12. this.initialColor = {r:255,g:255,b:255,a:1.0};
  13. this.previousColor= undefined;
  14. this.applied = false;
  15. // bound by
  16. this.updateCallback = () => {};
  17. this.closeCallback = () => {};
  18. // create all DOM elements
  19. this._create();
  20. }
  21. /**
  22. * this inserts the colorPicker into a div from the DOM
  23. * @param container
  24. */
  25. insertTo(container) {
  26. if (this.hammer !== undefined) {
  27. this.hammer.destroy();
  28. this.hammer = undefined;
  29. }
  30. this.container = container;
  31. this.container.appendChild(this.frame);
  32. this._bindHammer();
  33. this._setSize();
  34. }
  35. /**
  36. * the callback is executed on apply and save. Bind it to the application
  37. * @param callback
  38. */
  39. setUpdateCallback(callback) {
  40. if (typeof callback === 'function') {
  41. this.updateCallback = callback;
  42. }
  43. else {
  44. throw new Error("Function attempted to set as colorPicker update callback is not a function.");
  45. }
  46. }
  47. /**
  48. * the callback is executed on apply and save. Bind it to the application
  49. * @param callback
  50. */
  51. setCloseCallback(callback) {
  52. if (typeof callback === 'function') {
  53. this.closeCallback = callback;
  54. }
  55. else {
  56. throw new Error("Function attempted to set as colorPicker closing callback is not a function.");
  57. }
  58. }
  59. _isColorString(color) {
  60. var htmlColors = {black: '#000000',navy: '#000080',darkblue: '#00008B',mediumblue: '#0000CD',blue: '#0000FF',darkgreen: '#006400',green: '#008000',teal: '#008080',darkcyan: '#008B8B',deepskyblue: '#00BFFF',darkturquoise: '#00CED1',mediumspringgreen: '#00FA9A',lime: '#00FF00',springgreen: '#00FF7F',aqua: '#00FFFF',cyan: '#00FFFF',midnightblue: '#191970',dodgerblue: '#1E90FF',lightseagreen: '#20B2AA',forestgreen: '#228B22',seagreen: '#2E8B57',darkslategray: '#2F4F4F',limegreen: '#32CD32',mediumseagreen: '#3CB371',turquoise: '#40E0D0',royalblue: '#4169E1',steelblue: '#4682B4',darkslateblue: '#483D8B',mediumturquoise: '#48D1CC',indigo: '#4B0082',darkolivegreen: '#556B2F',cadetblue: '#5F9EA0',cornflowerblue: '#6495ED',mediumaquamarine: '#66CDAA',dimgray: '#696969',slateblue: '#6A5ACD',olivedrab: '#6B8E23',slategray: '#708090',lightslategray: '#778899',mediumslateblue: '#7B68EE',lawngreen: '#7CFC00',chartreuse: '#7FFF00',aquamarine: '#7FFFD4',maroon: '#800000',purple: '#800080',olive: '#808000',gray: '#808080',skyblue: '#87CEEB',lightskyblue: '#87CEFA',blueviolet: '#8A2BE2',darkred: '#8B0000',darkmagenta: '#8B008B',saddlebrown: '#8B4513',darkseagreen: '#8FBC8F',lightgreen: '#90EE90',mediumpurple: '#9370D8',darkviolet: '#9400D3',palegreen: '#98FB98',darkorchid: '#9932CC',yellowgreen: '#9ACD32',sienna: '#A0522D',brown: '#A52A2A',darkgray: '#A9A9A9',lightblue: '#ADD8E6',greenyellow: '#ADFF2F',paleturquoise: '#AFEEEE',lightsteelblue: '#B0C4DE',powderblue: '#B0E0E6',firebrick: '#B22222',darkgoldenrod: '#B8860B',mediumorchid: '#BA55D3',rosybrown: '#BC8F8F',darkkhaki: '#BDB76B',silver: '#C0C0C0',mediumvioletred: '#C71585',indianred: '#CD5C5C',peru: '#CD853F',chocolate: '#D2691E',tan: '#D2B48C',lightgrey: '#D3D3D3',palevioletred: '#D87093',thistle: '#D8BFD8',orchid: '#DA70D6',goldenrod: '#DAA520',crimson: '#DC143C',gainsboro: '#DCDCDC',plum: '#DDA0DD',burlywood: '#DEB887',lightcyan: '#E0FFFF',lavender: '#E6E6FA',darksalmon: '#E9967A',violet: '#EE82EE',palegoldenrod: '#EEE8AA',lightcoral: '#F08080',khaki: '#F0E68C',aliceblue: '#F0F8FF',honeydew: '#F0FFF0',azure: '#F0FFFF',sandybrown: '#F4A460',wheat: '#F5DEB3',beige: '#F5F5DC',whitesmoke: '#F5F5F5',mintcream: '#F5FFFA',ghostwhite: '#F8F8FF',salmon: '#FA8072',antiquewhite: '#FAEBD7',linen: '#FAF0E6',lightgoldenrodyellow: '#FAFAD2',oldlace: '#FDF5E6',red: '#FF0000',fuchsia: '#FF00FF',magenta: '#FF00FF',deeppink: '#FF1493',orangered: '#FF4500',tomato: '#FF6347',hotpink: '#FF69B4',coral: '#FF7F50',darkorange: '#FF8C00',lightsalmon: '#FFA07A',orange: '#FFA500',lightpink: '#FFB6C1',pink: '#FFC0CB',gold: '#FFD700',peachpuff: '#FFDAB9',navajowhite: '#FFDEAD',moccasin: '#FFE4B5',bisque: '#FFE4C4',mistyrose: '#FFE4E1',blanchedalmond: '#FFEBCD',papayawhip: '#FFEFD5',lavenderblush: '#FFF0F5',seashell: '#FFF5EE',cornsilk: '#FFF8DC',lemonchiffon: '#FFFACD',floralwhite: '#FFFAF0',snow: '#FFFAFA',yellow: '#FFFF00',lightyellow: '#FFFFE0',ivory: '#FFFFF0',white: '#FFFFFF'};
  61. if (typeof color === 'string') {
  62. return htmlColors[color];
  63. }
  64. }
  65. /**
  66. * Set the color of the colorPicker
  67. * Supported formats:
  68. * 'red' --> HTML color string
  69. * '#ffffff' --> hex string
  70. * 'rbg(255,255,255)' --> rgb string
  71. * 'rgba(255,255,255,1.0)' --> rgba string
  72. * {r:255,g:255,b:255} --> rgb object
  73. * {r:255,g:255,b:255,a:1.0} --> rgba object
  74. * @param color
  75. * @param setInitial
  76. */
  77. setColor(color, setInitial = true) {
  78. if (color === 'none') {
  79. return;
  80. }
  81. let rgba;
  82. // if a html color shorthand is used, convert to hex
  83. var htmlColor = this._isColorString(color);
  84. if (htmlColor !== undefined) {
  85. color = htmlColor;
  86. }
  87. // check format
  88. if (util.isString(color) === true) {
  89. if (util.isValidRGB(color) === true) {
  90. let rgbaArray = color.substr(4).substr(0, color.length - 5).split(',');
  91. rgba = {r:rgbaArray[0], g:rgbaArray[1], b:rgbaArray[2], a:1.0};
  92. }
  93. else if (util.isValidRGBA(color) === true) {
  94. let rgbaArray = color.substr(5).substr(0, color.length - 6).split(',');
  95. rgba = {r:rgbaArray[0], g:rgbaArray[1], b:rgbaArray[2], a:rgbaArray[3]};
  96. }
  97. else if (util.isValidHex(color) === true) {
  98. let rgbObj = util.hexToRGB(color);
  99. rgba = {r:rgbObj.r, g:rgbObj.g, b:rgbObj.b, a:1.0};
  100. }
  101. }
  102. else {
  103. if (color instanceof Object) {
  104. if (color.r !== undefined && color.g !== undefined && color.b !== undefined) {
  105. let alpha = color.a !== undefined ? color.a : '1.0';
  106. rgba = {r:color.r, g:color.g, b:color.b, a:alpha};
  107. }
  108. }
  109. }
  110. // set color
  111. if (rgba === undefined) {
  112. throw new Error("Unknown color passed to the colorPicker. Supported are strings: rgb, hex, rgba. Object: rgb ({r:r,g:g,b:b,[a:a]}). Supplied: " + JSON.stringify(color));
  113. }
  114. else {
  115. this._setColor(rgba, setInitial);
  116. }
  117. }
  118. /**
  119. * this shows the color picker.
  120. * The hue circle is constructed once and stored.
  121. */
  122. show() {
  123. if (this.closeCallback !== undefined) {
  124. this.closeCallback();
  125. this.closeCallback = undefined;
  126. }
  127. this.applied = false;
  128. this.frame.style.display = 'block';
  129. this._generateHueCircle();
  130. }
  131. // ------------------------------------------ PRIVATE ----------------------------- //
  132. /**
  133. * Hide the picker. Is called by the cancel button.
  134. * Optional boolean to store the previous color for easy access later on.
  135. * @param storePrevious
  136. * @private
  137. */
  138. _hide(storePrevious = true) {
  139. // store the previous color for next time;
  140. if (storePrevious === true) {
  141. this.previousColor = util.extend({}, this.color);
  142. }
  143. if (this.applied === true) {
  144. this.updateCallback(this.initialColor);
  145. }
  146. this.frame.style.display = 'none';
  147. // call the closing callback, restoring the onclick method.
  148. if (this.closeCallback !== undefined) {
  149. this.closeCallback();
  150. this.closeCallback = undefined;
  151. }
  152. }
  153. /**
  154. * bound to the save button. Saves and hides.
  155. * @private
  156. */
  157. _save() {
  158. this.updateCallback(this.color);
  159. this.applied = false;
  160. this._hide();
  161. }
  162. /**
  163. * Bound to apply button. Saves but does not close. Is undone by the cancel button.
  164. * @private
  165. */
  166. _apply() {
  167. this.applied = true;
  168. this.updateCallback(this.color);
  169. this._updatePicker(this.color);
  170. }
  171. /**
  172. * load the color from the previous session.
  173. * @private
  174. */
  175. _loadLast() {
  176. if (this.previousColor !== undefined) {
  177. this.setColor(this.previousColor, false);
  178. }
  179. else {
  180. alert("There is no last color to load...");
  181. }
  182. }
  183. /**
  184. * set the color, place the picker
  185. * @param rgba
  186. * @param setInitial
  187. * @private
  188. */
  189. _setColor(rgba, setInitial = true) {
  190. // store the initial color
  191. if (setInitial === true) {
  192. this.initialColor = util.extend({}, rgba);
  193. }
  194. this.color = rgba;
  195. let hsv = util.RGBToHSV(rgba.r, rgba.g, rgba.b);
  196. let angleConvert = 2 * Math.PI;
  197. let radius = this.r * hsv.s;
  198. let x = this.centerCoordinates.x + radius * Math.sin(angleConvert * hsv.h);
  199. let y = this.centerCoordinates.y + radius * Math.cos(angleConvert * hsv.h);
  200. this.colorPickerSelector.style.left = x - 0.5 * this.colorPickerSelector.clientWidth + 'px';
  201. this.colorPickerSelector.style.top = y - 0.5 * this.colorPickerSelector.clientHeight + 'px';
  202. this._updatePicker(rgba);
  203. }
  204. /**
  205. * bound to opacity control
  206. * @param value
  207. * @private
  208. */
  209. _setOpacity(value) {
  210. this.color.a = value / 100;
  211. this._updatePicker(this.color);
  212. }
  213. /**
  214. * bound to brightness control
  215. * @param value
  216. * @private
  217. */
  218. _setBrightness(value) {
  219. let hsv = util.RGBToHSV(this.color.r, this.color.g, this.color.b);
  220. hsv.v = value / 100;
  221. let rgba = util.HSVToRGB(hsv.h, hsv.s, hsv.v);
  222. rgba['a'] = this.color.a;
  223. this.color = rgba;
  224. this._updatePicker();
  225. }
  226. /**
  227. * update the color picker. A black circle overlays the hue circle to mimic the brightness decreasing.
  228. * @param rgba
  229. * @private
  230. */
  231. _updatePicker(rgba = this.color) {
  232. let hsv = util.RGBToHSV(rgba.r, rgba.g, rgba.b);
  233. let ctx = this.colorPickerCanvas.getContext('2d');
  234. if (this.pixelRation === undefined) {
  235. this.pixelRatio = (window.devicePixelRatio || 1) / (ctx.webkitBackingStorePixelRatio ||
  236. ctx.mozBackingStorePixelRatio ||
  237. ctx.msBackingStorePixelRatio ||
  238. ctx.oBackingStorePixelRatio ||
  239. ctx.backingStorePixelRatio || 1);
  240. }
  241. ctx.setTransform(this.pixelRatio, 0, 0, this.pixelRatio, 0, 0);
  242. // clear the canvas
  243. let w = this.colorPickerCanvas.clientWidth;
  244. let h = this.colorPickerCanvas.clientHeight;
  245. ctx.clearRect(0, 0, w, h);
  246. ctx.putImageData(this.hueCircle, 0,0);
  247. ctx.fillStyle = 'rgba(0,0,0,' + (1- hsv.v) + ')';
  248. ctx.circle(this.centerCoordinates.x, this.centerCoordinates.y, this.r);
  249. ctx.fill();
  250. this.brightnessRange.value = 100 * hsv.v;
  251. this.opacityRange.value = 100 * rgba.a;
  252. this.initialColorDiv.style.backgroundColor = 'rgba(' + this.initialColor.r + ',' + this.initialColor.g + ',' + this.initialColor.b + ',' + this.initialColor.a + ')';
  253. this.newColorDiv.style.backgroundColor = 'rgba(' + this.color.r + ',' + this.color.g + ',' + this.color.b + ',' + this.color.a + ')';
  254. }
  255. /**
  256. * used by create to set the size of the canvas.
  257. * @private
  258. */
  259. _setSize() {
  260. this.colorPickerCanvas.style.width = '100%';
  261. this.colorPickerCanvas.style.height = '100%';
  262. this.colorPickerCanvas.width = 289 * this.pixelRatio;
  263. this.colorPickerCanvas.height = 289 * this.pixelRatio;
  264. }
  265. /**
  266. * create all dom elements
  267. * TODO: cleanup, lots of similar dom elements
  268. * @private
  269. */
  270. _create() {
  271. this.frame = document.createElement('div');
  272. this.frame.className = 'vis-color-picker';
  273. this.colorPickerDiv = document.createElement('div');
  274. this.colorPickerSelector = document.createElement('div');
  275. this.colorPickerSelector.className = 'vis-selector';
  276. this.colorPickerDiv.appendChild(this.colorPickerSelector);
  277. this.colorPickerCanvas = document.createElement('canvas');
  278. this.colorPickerDiv.appendChild(this.colorPickerCanvas);
  279. if (!this.colorPickerCanvas.getContext) {
  280. let noCanvas = document.createElement( 'DIV' );
  281. noCanvas.style.color = 'red';
  282. noCanvas.style.fontWeight = 'bold' ;
  283. noCanvas.style.padding = '10px';
  284. noCanvas.innerHTML = 'Error: your browser does not support HTML canvas';
  285. this.colorPickerCanvas.appendChild(noCanvas);
  286. }
  287. else {
  288. let ctx = this.colorPickerCanvas.getContext("2d");
  289. this.pixelRatio = (window.devicePixelRatio || 1) / (ctx.webkitBackingStorePixelRatio ||
  290. ctx.mozBackingStorePixelRatio ||
  291. ctx.msBackingStorePixelRatio ||
  292. ctx.oBackingStorePixelRatio ||
  293. ctx.backingStorePixelRatio || 1);
  294. this.colorPickerCanvas.getContext("2d").setTransform(this.pixelRatio, 0, 0, this.pixelRatio, 0, 0);
  295. }
  296. this.colorPickerDiv.className = 'vis-color';
  297. this.opacityDiv = document.createElement('div');
  298. this.opacityDiv.className = 'vis-opacity';
  299. this.brightnessDiv = document.createElement('div');
  300. this.brightnessDiv.className = 'vis-brightness';
  301. this.arrowDiv = document.createElement('div');
  302. this.arrowDiv.className = 'vis-arrow';
  303. this.opacityRange = document.createElement('input');
  304. try {
  305. this.opacityRange.type = 'range'; // Not supported on IE9
  306. this.opacityRange.min = '0';
  307. this.opacityRange.max = '100';
  308. }
  309. catch (err) {}
  310. this.opacityRange.value = '100';
  311. this.opacityRange.className = 'vis-range';
  312. this.brightnessRange = document.createElement('input');
  313. try {
  314. this.brightnessRange.type = 'range'; // Not supported on IE9
  315. this.brightnessRange.min = '0';
  316. this.brightnessRange.max = '100';
  317. }
  318. catch (err) {}
  319. this.brightnessRange.value = '100';
  320. this.brightnessRange.className = 'vis-range';
  321. this.opacityDiv.appendChild(this.opacityRange);
  322. this.brightnessDiv.appendChild(this.brightnessRange);
  323. var me = this;
  324. this.opacityRange.onchange = function () {me._setOpacity(this.value);};
  325. this.opacityRange.oninput = function () {me._setOpacity(this.value);};
  326. this.brightnessRange.onchange = function () {me._setBrightness(this.value);};
  327. this.brightnessRange.oninput = function () {me._setBrightness(this.value);};
  328. this.brightnessLabel = document.createElement("div");
  329. this.brightnessLabel.className = "vis-label vis-brightness";
  330. this.brightnessLabel.innerHTML = 'brightness:';
  331. this.opacityLabel = document.createElement("div");
  332. this.opacityLabel.className = "vis-label vis-opacity";
  333. this.opacityLabel.innerHTML = 'opacity:';
  334. this.newColorDiv = document.createElement("div");
  335. this.newColorDiv.className = "vis-new-color";
  336. this.newColorDiv.innerHTML = 'new';
  337. this.initialColorDiv = document.createElement("div");
  338. this.initialColorDiv.className = "vis-initial-color";
  339. this.initialColorDiv.innerHTML = 'initial';
  340. this.cancelButton = document.createElement("div");
  341. this.cancelButton.className = "vis-button vis-cancel";
  342. this.cancelButton.innerHTML = 'cancel';
  343. this.cancelButton.onclick = this._hide.bind(this, false);
  344. this.applyButton = document.createElement("div");
  345. this.applyButton.className = "vis-button vis-apply";
  346. this.applyButton.innerHTML = 'apply';
  347. this.applyButton.onclick = this._apply.bind(this);
  348. this.saveButton = document.createElement("div");
  349. this.saveButton.className = "vis-button vis-save";
  350. this.saveButton.innerHTML = 'save';
  351. this.saveButton.onclick = this._save.bind(this);
  352. this.loadButton = document.createElement("div");
  353. this.loadButton.className = "vis-button vis-load";
  354. this.loadButton.innerHTML = 'load last';
  355. this.loadButton.onclick = this._loadLast.bind(this);
  356. this.frame.appendChild(this.colorPickerDiv);
  357. this.frame.appendChild(this.arrowDiv);
  358. this.frame.appendChild(this.brightnessLabel);
  359. this.frame.appendChild(this.brightnessDiv);
  360. this.frame.appendChild(this.opacityLabel);
  361. this.frame.appendChild(this.opacityDiv);
  362. this.frame.appendChild(this.newColorDiv);
  363. this.frame.appendChild(this.initialColorDiv);
  364. this.frame.appendChild(this.cancelButton);
  365. this.frame.appendChild(this.applyButton);
  366. this.frame.appendChild(this.saveButton);
  367. this.frame.appendChild(this.loadButton);
  368. }
  369. /**
  370. * bind hammer to the color picker
  371. * @private
  372. */
  373. _bindHammer() {
  374. this.drag = {};
  375. this.pinch = {};
  376. this.hammer = new Hammer(this.colorPickerCanvas);
  377. this.hammer.get('pinch').set({enable: true});
  378. hammerUtil.onTouch(this.hammer, (event) => {this._moveSelector(event)});
  379. this.hammer.on('tap', (event) => {this._moveSelector(event)});
  380. this.hammer.on('panstart', (event) => {this._moveSelector(event)});
  381. this.hammer.on('panmove', (event) => {this._moveSelector(event)});
  382. this.hammer.on('panend', (event) => {this._moveSelector(event)});
  383. }
  384. /**
  385. * generate the hue circle. This is relatively heavy (200ms) and is done only once on the first time it is shown.
  386. * @private
  387. */
  388. _generateHueCircle() {
  389. if (this.generated === false) {
  390. let ctx = this.colorPickerCanvas.getContext('2d');
  391. if (this.pixelRation === undefined) {
  392. this.pixelRatio = (window.devicePixelRatio || 1) / (ctx.webkitBackingStorePixelRatio ||
  393. ctx.mozBackingStorePixelRatio ||
  394. ctx.msBackingStorePixelRatio ||
  395. ctx.oBackingStorePixelRatio ||
  396. ctx.backingStorePixelRatio || 1);
  397. }
  398. ctx.setTransform(this.pixelRatio, 0, 0, this.pixelRatio, 0, 0);
  399. // clear the canvas
  400. let w = this.colorPickerCanvas.clientWidth;
  401. let h = this.colorPickerCanvas.clientHeight;
  402. ctx.clearRect(0, 0, w, h);
  403. // draw hue circle
  404. let x, y, hue, sat;
  405. this.centerCoordinates = {x: w * 0.5, y: h * 0.5};
  406. this.r = 0.49 * w;
  407. let angleConvert = (2 * Math.PI) / 360;
  408. let hfac = 1 / 360;
  409. let sfac = 1 / this.r;
  410. let rgb;
  411. for (hue = 0; hue < 360; hue++) {
  412. for (sat = 0; sat < this.r; sat++) {
  413. x = this.centerCoordinates.x + sat * Math.sin(angleConvert * hue);
  414. y = this.centerCoordinates.y + sat * Math.cos(angleConvert * hue);
  415. rgb = util.HSVToRGB(hue * hfac, sat * sfac, 1);
  416. ctx.fillStyle = 'rgb(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ')';
  417. ctx.fillRect(x - 0.5, y - 0.5, 2, 2);
  418. }
  419. }
  420. ctx.strokeStyle = 'rgba(0,0,0,1)';
  421. ctx.circle(this.centerCoordinates.x, this.centerCoordinates.y, this.r);
  422. ctx.stroke();
  423. this.hueCircle = ctx.getImageData(0,0,w,h);
  424. }
  425. this.generated = true;
  426. }
  427. /**
  428. * move the selector. This is called by hammer functions.
  429. *
  430. * @param event
  431. * @private
  432. */
  433. _moveSelector(event) {
  434. let rect = this.colorPickerDiv.getBoundingClientRect();
  435. let left = event.center.x - rect.left;
  436. let top = event.center.y - rect.top;
  437. let centerY = 0.5 * this.colorPickerDiv.clientHeight;
  438. let centerX = 0.5 * this.colorPickerDiv.clientWidth;
  439. let x = left - centerX;
  440. let y = top - centerY;
  441. let angle = Math.atan2(x,y);
  442. let radius = 0.98 * Math.min(Math.sqrt(x * x + y * y), centerX);
  443. let newTop = Math.cos(angle) * radius + centerY;
  444. let newLeft = Math.sin(angle) * radius + centerX;
  445. this.colorPickerSelector.style.top = newTop - 0.5 * this.colorPickerSelector.clientHeight + 'px';
  446. this.colorPickerSelector.style.left = newLeft - 0.5 * this.colorPickerSelector.clientWidth + 'px';
  447. // set color
  448. let h = angle / (2 * Math.PI);
  449. h = h < 0 ? h + 1 : h;
  450. let s = radius / this.r;
  451. let hsv = util.RGBToHSV(this.color.r, this.color.g, this.color.b);
  452. hsv.h = h;
  453. hsv.s = s;
  454. let rgba = util.HSVToRGB(hsv.h, hsv.s, hsv.v);
  455. rgba['a'] = this.color.a;
  456. this.color = rgba;
  457. // update previews
  458. this.initialColorDiv.style.backgroundColor = 'rgba(' + this.initialColor.r + ',' + this.initialColor.g + ',' + this.initialColor.b + ',' + this.initialColor.a + ')';
  459. this.newColorDiv.style.backgroundColor = 'rgba(' + this.color.r + ',' + this.color.g + ',' + this.color.b + ',' + this.color.a + ')';
  460. }
  461. }
  462. export default ColorPicker;