mirror of
				https://github.com/reduxjs/redux-devtools.git
				synced 2025-10-31 16:07:45 +03:00 
			
		
		
		
	
		
			
				
	
	
		
			17 lines
		
	
	
		
			455 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			17 lines
		
	
	
		
			455 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| export default function (hexColor: string, lightness: number) {
 | |
|   let hex = String(hexColor).replace(/[^0-9a-f]/gi, '');
 | |
|   if (hex.length < 6) {
 | |
|     hex = hex.replace(/(.)/g, '$1$1');
 | |
|   }
 | |
|   const lum = lightness || 0;
 | |
| 
 | |
|   let rgb = '#';
 | |
|   let c;
 | |
|   for (let i = 0; i < 3; ++i) {
 | |
|     c = parseInt(hex.substr(i * 2, 2), 16);
 | |
|     c = Math.round(Math.min(Math.max(0, c + c * lum), 255)).toString(16);
 | |
|     rgb += ('00' + c).substr(c.length);
 | |
|   }
 | |
|   return rgb;
 | |
| }
 |