-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0ca0cee
commit e30dfd2
Showing
46 changed files
with
7,879 additions
and
1,547 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
function bright($hex, $adjustment){ | ||
|
||
$adjustment = max(-255, min(255, $adjustment)); // Adjustment value is between 255 & -255 | ||
$hex = str_replace('#', '', $hex); //Remove # from string | ||
|
||
//if hex value is 3 numbers set to 6 | ||
if (strlen($hex) == 3){ | ||
$hex = str_repeat(substr($hex,0,1), 2).str_repeat(substr($hex,1,1), 2).str_repeat(substr($hex,2,1), 2); | ||
} | ||
|
||
$colors = str_split($hex, 2); //split values into three channels | ||
$adjusted_value = '#'; | ||
|
||
foreach($colors as $color) { | ||
$color = hexdec($color); //convert to decimal | ||
$color = max(0, min(255, $color + $adjustment)); //perform adjustment | ||
$adjusted_value .= str_pad(dechex($color), 2, '0', STR_PAD_LEFT); //make two character hex code | ||
} | ||
|
||
return $adjusted_value; | ||
} | ||
|
||
?> |
Oops, something went wrong.