تابع ووکامرسی wc_hex_lighter تغییر کد رنگ به تاریک / روشن ( تر )

تابع ووکامرسی wc_hex_lighter – تغییر کد رنگ به تاریک / روشن ( تر )
Syntax – سینتکس
(string) wc_hex_lighter( (mixed) $color, (int) $factor = 30 );
Parameters – پارامتر ها (2)
- 1- $color (mixed)
- 2- $factor (int)
Usage – نحوه استفاده
if ( !function_exists( 'wc_hex_lighter' ) ) {
require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-formatting-functions.php';
}
// The color.
$color = null;
// (default: 30)
$factor = 30;
// NOTICE! Understand what this does before running.
$result = wc_hex_lighter($color, $factor);
Defined – محل تعریف
/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;
}
versions – نسخه ها
از نسخه : 3.0.2
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر