Created
March 5, 2023 17:51
-
-
Save levonlee/2688836084594ea4877088a7dec13f00 to your computer and use it in GitHub Desktop.
PHP Color Shade and Tint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$currentR = 66; | |
$currentG = 85; | |
$currentB = 123; | |
$effect = 'tint'; | |
$alpha = 0.1; | |
list($aR, $aG, $aB) = (function () use ($effect) { | |
switch ($effect) { | |
case 'shade': | |
return [0, 0, 0]; | |
case 'tint': | |
return [255, 255, 255]; | |
case 'tone': | |
default: | |
return [128, 128, 128]; | |
} | |
})(); | |
var_dump(array( | |
$currentR + ($aR - $currentR) * $alpha, | |
$currentG + ($aG - $currentG) * $alpha, | |
$currentB + ($aB - $currentB) * $alpha, | |
)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment