mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-18 12:52:52 +00:00
rgbaToHex color converter implemented
This commit is contained in:
parent
a660c1343b
commit
ed0f6742b2
1 changed files with 12 additions and 0 deletions
12
src/routes/Player/Video/stremio-video/colorConverter.js
Normal file
12
src/routes/Player/Video/stremio-video/colorConverter.js
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
function rgbaToHex(rgbaString) {
|
||||
var values = rgbaString.split('(')[1].split(')')[0].split(',');
|
||||
var red = parseInt(values[0]).toString(16);
|
||||
var green = parseInt(values[1]).toString(16);
|
||||
var blue = parseInt(values[2]).toString(16);
|
||||
var alpha = typeof values[3] === 'string' ? Math.round(values[3] * 255).toString(16) : '00';
|
||||
return '#' + red + green + blue + alpha;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
rgbaToHex
|
||||
};
|
||||
Loading…
Reference in a new issue