Horje
Convert RGB To Hex Code Example
javascript rgb to hex
function rgbToHex(r, g, b) {
  return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
}

function hexToRgb(hex) {
  var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
  if(result){
      var r= parseInt(result[1], 16);
      var g= parseInt(result[2], 16);
      var b= parseInt(result[3], 16);
      return r+","+g+","+b;//return 23,14,45 -> reformat if needed 
  } 
  return null;
}
console.log(rgbToHex(10, 54, 120)); //#0a3678
console.log(hexToRgb("#0a3678"));//"10,54,120"
rgb to hex
function rgb(r, g, b){
  function toHex(a) { 
    if (a <= 0) return '00';
    else if (a >= 255) return 'FF';
    else return a.toString(16).toUpperCase();
  }
  return toHex(r) + toHex(g) + toHex(b);
}
Convert RGB To Hex
const rgbToHex = (r, g, b) =>
  "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);

rgbToHex(0, 51, 255); 
// Result: #0033ff
Source: dev.to
rgb to hex conversion
// rgb to hex conversion
fn rgb(r: i32, g: i32, b: i32) -> String {
    format!("{:02X}{:02X}{:02X}", 
        r as f32 as u8, 
        g as f32 as u8, 
        b as f32 as u8) 
}

fn main() {
    let (r, g, b) = (123, 86, 200);
    println!("rgb {} {} {} to hex {} ", r, g, b, rgb(r, g, b));
}
RGB To HEX Color Converter
RGB To HEX Color Converter:
https://freetoolssite.com/tools/rgb-to-hex-color-converter




Javascript

Related
javascript function with string parameter Code Example javascript function with string parameter Code Example
jsonarray find Code Example jsonarray find Code Example
js delete all from array Code Example js delete all from array Code Example
What is JSON? Code Example What is JSON? Code Example
react native add bottom tab and drawer menu Code Example react native add bottom tab and drawer menu Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7