Skip to content

Documentation / @andrew_l/toolkit / parseAlpha

Function: parseAlpha() ​

parseAlpha(value, fallback): number

Parse alpha channel value and normalize it from 0 to 1

Parameters ​

value ​

unknown

Value to be parsed

fallback ​

number = 1

Value which will be used as fallback when failed to parse

Returns ​

number

Example ​

ts
parseAlpha('0.1'); // 0.1
parseAlpha('10%'); // 0.1
parseAlpha(0.1); // 0.1