Transparent ARGB hex value

前端 未结 7 1955
天命终不由人
天命终不由人 2020-11-28 17:16

The colors in this table is all not transparent. I guess the value for the A is set to FF.

What is the code for transparency?

For

7条回答
  •  自闭症患者
    2020-11-28 17:49

    If you have your hex value, and your just wondering what the value for the alpha would be, this snippet may help:

    const alphaToHex = (alpha => {
      if (alpha > 1 || alpha < 0 || isNaN(alpha)) {
        throw new Error('The argument must be a number between 0 and 1');
      }
      return Math.ceil(255 * alpha).toString(16).toUpperCase();
    })
    
    console.log(alphaToHex(0.45));

提交回复
热议问题