Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Abyss
- $abyss = array(-18, 1, 275, 0.0234375, 1.09375);
- // White
- $white = array(45, 1.44531, 10, 0.0234375, 1.5625);
- // Grape
- $grape = array(-3,1,305,0.507813,0.937500);
- // Hot Pink
- $hotpink = array(14, 1.21094, 340, 0.820313, 1.44531);
- // Grapevine
- $grapevine = array(2, 1, 270, 0.507813, 1.09375);
- header('Content-type: image/png');
- $imagebkpath = './backgrounds/1.png';
- $image1path = './emblems/2a.png';
- $image2path = './emblems/2b.png';
- $image_bk = imagecreatefrompng($imagebkpath);
- $image_1 = imagecreatefrompng($image1path);
- $image_2 = imagecreatefrompng($image2path);
- $background = imagecolorallocate($image_bk, 0,0,0);
- imagecolortransparent($image_bk, $background);
- imagealphablending($image_bk, true);
- imagesavealpha($image_bk, true);
- imagehue($image_bk, $abyss[0],$abyss[1],$abyss[2],$abyss[3],$abyss[4]);
- imagehue($image_1, $white[0],$white[1],$white[2],$white[3],$white[4]);
- imagehue($image_2, $grape[0],$grape[1],$grape[2],$grape[3],$grape[4]);
- imagecopy($image_1, $image_2, 0, 0, 0, 0, 256, 256);
- imagecopy($image_bk, $image_1, 0, 0, 0, 0, 256, 256);
- imagepng($image_bk);
- imagedestroy($image_bk);
- imagedestroy($image_1);
- imagedestroy($image_2);
- function imagehue(&$image, $b,$c,$h,$s,$l) {
- $width = imagesx($image);
- $height = imagesy($image);
- for($x = 0; $x < $width; $x++) {
- for($y = 0; $y < $height; $y++) {
- $rgb = imagecolorat($image, $x, $y);
- $r = ($rgb >> 16) & 0xFF;
- $g = ($rgb >> 8) & 0xFF;
- $b = $rgb & 0xFF;
- $alpha = ($rgb & 0x7F000000) >> 24;
- $rgb = array(128,26,26);
- $rgb = shiftColour($rgb,$b,$c,$h,$s,$l);
- imagesetpixel($image, $x, $y, imagecolorallocatealpha($image, $rgb[0], $rgb[1], $rgb[2], $alpha));
- }
- }
- }
- // shiftColour from https://gist.github.com/codemasher/fb407de5587fdbd3e7c5
- function shiftColour($rgb,$b,$c,$h,$s,$l){
- $rgb = rgb_BC($rgb,$b,$c);
- $hsl = rgb2hsl($rgb);
- $hsl[0] = ($hsl[0]*360+$h)/360;
- $hsl[1] = $hsl[1] * $s;
- $hsl[2] = $hsl[2] * $l;
- $rgb = hsl2rgb($hsl);
- return $rgb;
- }
- // rgb_BC from code here: https://gist.github.com/codemasher/fb407de5587fdbd3e7c5
- function rgb_BC($rgb,$b,$c){
- foreach($rgb as $k => $v){
- $rgb[$k] = (($v+$b)-128) * $c+128;
- }
- return $rgb;
- }
- //rgb2hsl from code here: https://gist.github.com/codemasher/741f30e68c6e9c7921c7
- function rgb2hsl($rgb){
- $r = $rgb[0]/255;
- $g = $rgb[1]/255;
- $b = $rgb[2]/255;
- $min = min($r, $g, $b);
- $max = max($r, $g, $b);
- $d = $max-$min;
- $h = $s = 0;
- $l = ($max+$min)/2;
- if($d > 0){
- $s = $l > 0.5 ? $d/(2-$max-$min) : $d/($max+$min);
- switch($max){
- case $r: $h = ($g-$b)/$d+($g < $b ? 6 : 0); break;
- case $g: $h = ($b-$r)/$d+2; break;
- case $b: $h = ($r-$g)/$d+4; break;
- }
- $h /= 6;
- }
- return array($h, $s, $l);
- }
- // hsl2rgb from code here: https://gist.github.com/codemasher/741f30e68c6e9c7921c7
- function hsl2rgb($hsl){
- $h = $hsl[0];
- $s = $hsl[1];
- $l = $hsl[2];
- $r = $g = $b = $l;
- if($s <> 0){
- $q = $l < 0.5 ? $l*(1+$s) : $l+$s-$l*$s;
- $p = 2*$l-$q;
- $r = hue2rgb($p, $q, $h+1/3);
- $g = hue2rgb($p, $q, $h);
- $b = hue2rgb($p, $q, $h-1/3);
- }
- return array($r*255, $g*255, $b*255);
- }
- // hue2rgb from code here: https://gist.github.com/codemasher/741f30e68c6e9c7921c7
- function hue2rgb($p, $q, $t){
- if($t < 0) $t += 1;
- if($t > 1) $t -= 1;
- if($t < 1/6) return $p+($q-$p)*6*$t;
- if($t < 1/2) return $q;
- if($t < 2/3) return $p+($q-$p)*(2/3-$t)*6;
- return $p;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement