📜  typescript 将颜色转换为 rgb - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:35.380000             🧑  作者: Mango

代码示例4
function componentToHex(c) {
  var hex = c.toString(16);
  return hex.length == 1 ? "0" + hex : hex;
}

function rgbToHex(r, g, b) {
  return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
}

alert(rgbToHex(0, 51, 255)); // #0033ff