typescript convert color to rgb

Solutions on MaxInterview for typescript convert color to rgb by the best coders in the world

showing results for - "typescript convert color to rgb"
Emil
16 Jan 2020
1function rgbToHex(r, g, b) {
2  return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
3}
4
5function hexToRgb(hex) {
6  var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
7  if(result){
8      var r= parseInt(result[1], 16);
9      var g= parseInt(result[2], 16);
10      var b= parseInt(result[3], 16);
11      return r+","+g+","+b;//return 23,14,45 -> reformat if needed 
12  } 
13  return null;
14}
15console.log(rgbToHex(10, 54, 120)); //#0a3678
16console.log(hexToRgb("#0a3678"));//"10,54,120"
Julian
20 Aug 2018
1function hexToRgb(hex) {
2  // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
3  var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
4  hex = hex.replace(shorthandRegex, function(m, r, g, b) {
5    return r + r + g + g + b + b;
6  });
7
8  var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
9  return result ? [
10    parseInt(result[1], 16),
11    parseInt(result[2], 16),
12    parseInt(result[3], 16)
13  ] : null;
14}
15
16alert(hexToRgb("#0033ff").g); // "51";
17alert(hexToRgb("#03f").g); // "51";
Leroy
29 Jul 2016
1function hexToRgb(hex) {
2  var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
3  return result ? {
4    r: parseInt(result[1], 16),
5    g: parseInt(result[2], 16),
6    b: parseInt(result[3], 16)
7  } : null;
8}
9
10alert(hexToRgb("#0033ff").g); // "51";
Sara
09 Jul 2018
1function componentToHex(c) {
2  var hex = c.toString(16);
3  return hex.length == 1 ? "0" + hex : hex;
4}
5
6function rgbToHex(r, g, b) {
7  return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
8}
9
10alert(rgbToHex(0, 51, 255)); // #0033ff
queries leading to this page
function hex to rgb stack overflowconvert rgb hex to rgb javascriptjavascript convert hex to rgbhex number to rgb jsrgb hex converter javascript from htmlrgb to hex jaavscriptconvert color to hex javascriptrgb to decimal code javscriptcolor rgb to hex javascriptjavascript hex to rgbapass rgb to hexjshex color to int javascripttransform rgb to hex javascriptconvert rgb value to hex javascriptreturn 28 colordigits map 28c 3d 3e 60 24 7bc 3c 10 3f 270 27 3a 27 27 7d 24 7bc tostring 2816 29 7d 60 29 join 28 27 27 29 29color rgb to hex jsjavascript convert number in color to rgbjavascript convert color string to rgbjs convert hex into rgb and hsl 27hextorgb 27 is not definedtypescript convert color to rgbrgb to 23 javascriptconvert rgb color to hex javascriptchange hex to rgb jsjavascript hex to rbjs function that convert rgba into hexconvert hex color to rgb in jsjavascript get rgb from hex numbertransform hexa to rgba jsconvert hex to rgba javascriptrgb to color jsreact diseable convert code color to rgbjavascript hrx to rgbjs rgb to hex colorhow to convert an r 2c g 2c and b to a hex code in jsjavascript function rgb to hexjs color rgb to hejs get rgb from hexhow to convert rgb to hexadecimal in javascrptjavascript convert hex to rgbarbg to hexcodes in jscolor hex to rgb jscss rgb to hex jsget decimal color from hex javascripthex to rgb typescriptget rgb from hex javascriptrgb decimal to hex javascripthow to convert rgba to hex in javascripthex code to rgb javascriptjs to rb converterhexa to rgb jshow to convert rgb colors to hexadecimal with javascriptblue to hex jshex to rgb converter javascriptconvert hex color to rgb jsjavascript color string to rgbjs convert hex to rgbargb to hsl javascriptrgb to hexconvert rgba to hex in jsjs rbg to hexjs style rgb to hexreact convert color to hexhex to rgb and rgb to hex javscriptjavascript hex code to rgbrgb to hex javascript algorithmwork with rgb in javascriptrgb to hex color javascriptjavascript change rgb to hexcalculate rgb to hex jsjavascript rpg to hexjs get color with bit formatrgb2hex javascriptrgb string to hex in javascriptdiscord js color with rgbhex to rgb angularconvert r g b to hex javascripttransform hex to rgb jsconvert rgb 2825 2c 0 2c 0 29 string to hex javascriptrgba to hexhex javascriptrgb channels to hex jstypescript hex to rgbrgb string to hex converter javascript rgb to hex in jshex string to rgb javascripthexadecimal to rgb jsjavascript rgb to hexadecimalhow to get only the red value in the rgb with javascriptfind the whole spectrum of a hex color jshow to convert hex into rgb color in javascripthex to rgb functionconver rgb to hex color jsrgb to hex conversion function in javascripthextorgbarrayjavascript hextorgbrgb to hexadecimal javascriptjavascript how to convert hex to rgbhextorgb typescriptrgb to hex conversion javascript codewarsrgb to hex conversion jsget rgb from hex jsget hex code from rgb jqueryjs rgb from hexjs comvert rgb to hexconvert rgb to hex code in javascriptjavadcript hex to rgbconvert hex to rgbconvert rgb to hex javascripthow to convert color to rgb with javascripthax to rgbhex to rgb js rgb to hex javascript codehex to rgb javascript functionconvert hex to rgba jsjavascript convert color from hex to rgbjs hex to rgba converterconvert color to rgb jsconvert rgba to hex javascriptrgb to hex and back javascriptrgb to hex function javascriptrgb to hex jschange hex to rgb javascripthex color to rgb javascriptjavascript convert rgb string color to hexmapping from decimal to hex javascript colorjavascript rgb to exadecimaleget rgba to hex javascripthex to rgb jasconvert hex string to rgb javascriptconvert hex color code to rgb javascripthex to rgb in javascripthex to rgb conversion javascripthextorgb js not foundger rgb equivalent to string color javsctipstypescript rgb to hexparse hex into color jsget rgba from hex javascriptjs get convert color to rgbconvert rgb color value to number javascriptjavascript rgba to hexjs rgba to hexjavascript rgb to hex codeconvert rgb to hexhex to rgb string in jsrgb to hex conversion javascriptjava script rgb to hexchange color of an integer javascriptconvert hex to rgb javascript functionfunction to convert rgb to hex jscolor hexadecimal to rgb jshex to rgba javascriptjs rgb to hexget hex to rgb javascript3 rgb numbers to hex node jsconvert 23rrggbb to 23rgb jshexcolor to rgbjavascriptcolor input convert to rgb javascriptconvert rgba to hex javascript onlineconvert rgb to hex typescriptconvert hex to rgb functionhexcolor to number javascriptjs hex to rgb arrayrgb to hex javascriptconvert rgb to hsl javascriptget color in hex format jsjs go from green to red as object gets largerjavascript rgb to hechexstring to rgb array jscolor to hex jsjavascript convert number in rgbhex to rgb js functionjs from hex to rgbtransform rgb to hex jsjavascript rgb to stringrgb color to hex javascriptconvert rgb to hexadecimal javascripthex to rgb javascriptjs hex to hsl and rgbjavascript convert rgb string to hexjs hex color to rgbrgb to hex in javascriptrgb to hex conversion codewars javascriptrgba to hex converter javascriptjavascript from rgb to hexrgb to hexjshow to change rgb to hex javascriptrgba to hex javacsripthow to convert hex into rgba in jsconvert hexa to rgb javascriptrgb to hexadecimal notation jsjs hexa to rgb converterhex to srgb hex jshex to rgb color converter javascriptconvert rgb color object into number jsde hexadecimal a rgb jshex characters to rgb jsvariable color rgb to hex javascriptconvert rgb string to hex javascriptis there a function to convert rgb to hex javascriptrgb color typescriptif i set hex color by java it converted to rgb automatically why 3fjs convert rgbr to hexjs hex array to rgbjavascript hex color to rgbreturn rgb int from hexhow to change a hex code into rgb in javascriptjavascript get rgb values from hexcolor convert rgb to hex 220x 22javascript convert rgb to hex colorconvert rgb to hex javascriptpactypescript convert number to hex colorhex to rgba jsrgb to string javascriptfunction rgb to hexaconvert hex to rgb javascriptjavascript rgb to hexhow to convert hexadecimal color code to rgb in javascriptconvert rgb to hex in javascriptjs convert rgb to hexadecimalhex to rgb convert javascripthow to combine rgb to hexa javargb to hex color jsrgb hex converter javascriptjs convert hexcolor to rgbconvert pantone to rgb 2bjavascriptconvert rgba to hex in javascripthow to convert rgb to hexadecimal in javascriptconvert rgb style value to hex value 2c javascriptfrom hexadecimal to color jsjs rgb to hexadecimalhex to rgb color typescriptjavascript rgb to hexafrom rbg 28r 2cg 2cb 29 to int jscolor hex to rgba javascriptrgb para hexadecimal jsconvert regb to hex angularjavascript rgb to hex conversion 5 kyujs convert code to hexrgb to hex conversion javascriptjavascript convert rgb to hexturn hex to rgb jsnodejs hex to rgbtypescript rgb to hex convertrgb to hex converter javascripthexa to rgb javascript functioncolor rgb to hex 220x 22function to convert color rgbhex to rgba convert javascripthow to convert rgb into hex jsjavascript function to convert hex to rgbhex to rgbconvert color hex to rgb jsconverting rgb to hex javascripttransform hex to rgba jsjshex to rgbjs how to convert rgb to hexconvert color to rgb javascriptchange rgb to hexidecimals jshex rgb converter javascriptconvert rgh to hex jsjs for converting hex to rgbconver rgba to hexa by javascriptconvert hex code to rgb javascriptrgb ot hex jstypescript convert color to hexrgbtohex functionjs return rgb value from rangejs convert hex to rgbconvert hex to rgb jsjavascript convert rbg to hexfrom hex to rgbjs color to rgbrgb 28 29 to hex jsconvert hash color to rgb with javascriptjavascript rbg to hexjs rgb to hex why 16rgb to hex js codejs convert hex string into rgbhow to convert hex to rgb in javascriptjs rgb to hexconvert hex to rgb es6convert rgb to hex javascript functionrgba to hex in jsnode js hex to rgbjs rgb to 0xrgbcolor to rgb jsconvert rgb to hex color javascriptrgb to hexjavascriptjavascript convert a hex string to rgbjs convert hex color to rgbjavascript get rgb from hexjs convert rgb to hexjs hexa to rgbconvert hex color to rgb in javascriptjavascript convert hex code to htmlrgba to hex jsjs convert color hex code to rgbrgb to hex convertor javascriptfrom rgb to hex jsjavascript convert rgb to hexadecimalcovert rgb to hex jsjavascript function to convert rgb to hexconvert rgb to hex jsconvertir color hx a rgb en javascriptjs hex to rgb colorhex to rgb nodejsjs hex to rgbahow to convert hex to rgb javascriptsimple rgb to hex jshex to srgb jsrgba to hex javascripthexacimal color to rgb functionrgbtohex javascriptfrom rgb to hex javascriptcovert hex to rgb jsconverting rgb value to hexcodei n jsjs add white to hexhex code to rgba javascripthow to convert rgb to hex javascripthex to rgb on javascriptconvert from hex to rgb jscovnert hex to rbg with javascriptrjavascript convert rgb into hexconvert rbg a to hex jsjavascript hex inverterhow to convert 8 digit hex to rgb in javascriptjs hex to rgb converterfrom hex to rgb javascriptconvert hex to rgb javascrithow to convert rgb to hex in javascriptjs hex to rgbconvert hex color to rgb javascript and returns its an arryjavascript convert hexadecimal to rgbone color rgb to hex jsjavascript hex to rgbjs hex character to rgbparse brazilian color to hexadecimal javascriptjavascript convert rgb color as hexjs change hex to rgbfunction from hex to rgb reactfunction hextorgb stackoverflowhow to convert hex to rgb in reacthow to convert rgb to hexconvert rgb to hex javascript onlinejavascript to convery hex to rgbaconvert hex color to rgb javascripthextorgb jstypescript convert color to rgb