function designkit_colorshift in DesignKit 7
Same name and namespace in other branches
- 6 designkit.module \designkit_colorshift()
Apply a shift color to a source color by a certain opacity value.
Parameters
$source: An RGB hex string. The source color to which a shift should be applied. @param $shift An RGB hex string. The shift color which defines the color that the source should shift towards. @param $opacity A float between 0 and 1 that determines what opacity to use for the blending shift color. @return An RGB hex string.
File
- ./
designkit.module, line 202
Code
function designkit_colorshift($source, $shift, $opacity = 0.5) {
if (designkit_valid_color($source) && designkit_valid_color($shift)) {
$source = _color_unpack($source, TRUE);
$shift = _color_unpack($shift, TRUE);
$shifted = array();
foreach (array_keys($source) as $key) {
// shifted = original color + (difference * opacity).
$shifted[$key] = $source[$key] + ($shift[$key] - $source[$key]) * $opacity;
}
return _color_pack($shifted, TRUE);
}
return $source;
}