wc_hex_lighter( mixed $color, int $factor = 30 )
Make HEX color lighter.
Description Description
Parameters Parameters
- $color
-
(Required) Color.
- $factor
-
(Optional) Lighter factor. Defaults to 30.
Default value: 30
Return Return
(string)
Source Source
File: includes/wc-formatting-functions.php
function wc_hex_lighter( $color, $factor = 30 ) { $base = wc_rgb_from_hex( $color ); $color = '#'; foreach ( $base as $k => $v ) { $amount = 255 - $v; $amount = $amount / 100; $amount = round( $amount * $factor ); $new_decimal = $v + $amount; $new_hex_component = dechex( $new_decimal ); if ( strlen( $new_hex_component ) < 2 ) { $new_hex_component = '0' . $new_hex_component; } $color .= $new_hex_component; } return $color; }