javascript add alpha to hex
function addAlpha(color: string, opacity: number): string {
// coerce values so ti is between 0 and 1.
const _opacity = Math.round(Math.min(Math.max(opacity || 1, 0), 1) * 255);
return color + _opacity.toString(16).toUpperCase();
}
addAlpha('FF0000', 1); // returns 'FF0000FF'
addAlpha('FF0000', 0.5); // returns 'FF000080'
Also in JavaScript:
- recursive inquirerjs prompts
- javascript modal show
- quick sort js
- postgresql nodejs
- httpclient post c# json
- ng has unexpectedly closed (exit code 127).
- remove last character from string jquery
- set auto width sheetjs
- how to use for of in javascript
- jquery example sheetjs
- add 10px to width js
- discord.js send message to specific channel
- js implement hot reload
- Regular Expressions: Extract Matches
- react js documentation
- using aria attributes in angular
- jquery on dom change
- chart.js line chart animation on canvas update react class state
- how to remove backslash from string in javascript
- p5js click on button
- queryselector by class javascript
- js push array
- get json data when we get error code in axios
- how to get all elements with same class in javascript