<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>16进制颜色 -> rgb</title>
</head>
<body>
<script>
let pointColor = "#ff0000";
// rgb(255, 0, 0)
// 此处16必须有,否则不能转换,返回NaN。
let r = parseInt(pointColor.slice(1, 3), 16);
console.log(r); // 255
let g = parseInt(pointColor.slice(3, 5), 16);
console.log(g); // 0
let b = parseInt(pointColor.slice(5), 16);
console.log(b); // 0
let pointTransparency = "128";
let a = parseInt(pointTransparency) / 255;
console.log(a); // 0.5019607843137255
</script>
</body>
</html>
<!doctype html>
<html lang="en">
<head>
<meta cha