Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

convert hsl to hex code javascript

function hslToHex(h, s, l) {
  l /= 100;
  const a = s * Math.min(l, 1 - l) / 100;
  const f = n => {
    const k = (n + h / 30) % 12;
    const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
    return Math.round(255 * color).toString(16).padStart(2, '0');   // convert to Hex and prefix "0" if needed
  };
  return `#${f(0)}${f(8)}${f(4)}`;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: js remove quotes from string 
Javascript :: remove event listener react hooks 
Javascript :: how to put variable in string javascript 
Javascript :: exit application node js 
Javascript :: remove file from input type file jquery 
Javascript :: javascript absolute value 
Javascript :: truthy or falsy value javascript 
Javascript :: curl accept json 
Javascript :: how to change the font family using jquery 
Javascript :: use set to remove duplicates in javascript 
Javascript :: convert file into base64 in javascript 
Javascript :: javascript size of variable in kb 
Javascript :: console.log red text on yellow background 
Javascript :: how to delete all slash command discord.js 
Javascript :: prompt box to integer 
Javascript :: increase font size in jsx 
Javascript :: npm react redux logger 
Javascript :: CocoaPods could not find compatible versions for pod "ReactCommon/jscallinvoker" 
Javascript :: how to convert time to am pm in javascript 
Javascript :: tomodachi 
Javascript :: js random number 
Javascript :: print a specific div in javascript 
Javascript :: detect browser 
Javascript :: how to get aria expanded value in javascript 
Javascript :: js array for in vs for of 
Javascript :: change inner html jquery 
Javascript :: javascript test if element has focus 
Javascript :: scroll page to top after ajax success 
Javascript :: node redis json push to array 
Javascript :: regex not ending with 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =