[ Index ] |
|
Code source de phpMyVisites 2.3 |
1 <?php 2 /** 3 * ClickHeat : crée sur disque et renvoie le logo PNG 80x15 / creates on disk and returns the PNG 80x15 logo 4 * 5 * @author Yvan Taviaud - LabsMedia - www.labsmedia.com 6 * @since 31/10/2006 7 **/ 8 9 define('CLICKHEAT_GREY_COLOR', 255); 10 define('CLICKHEAT_LOW_COLOR', 0); 11 define('CLICKHEAT_HIGH_COLOR', 255); 12 13 /** Image creation */ 14 $img = imagecreatetruecolor(170, 35); 15 $white = imagecolorallocate($img, 255, 255, 255); 16 $blue = imagecolorallocate($img, 70, 70, 255); 17 $red = imagecolorallocate($img, 255, 70, 70); 18 $black = imagecolorallocate($img, 0, 0, 0); 19 $shadow = imagecolorallocate($img, 200, 200, 255); 20 //imagefill($img, 0, 0, $shadow); 21 22 /** 23 * Colors creation : 24 * grey => deep blue (rgB) => light blue (rGB) => green (rGb) => yellow (RGb) => red (Rgb) 25 * 0 $colorLevels[0] $colorLevels[1] $colorLevels[2] $colorLevels[3] 128 26 **/ 27 $colorLevels = array(30, 55, 65, 75); 28 $colors = array(); 29 for ($i = 0; $i < 128; $i++) 30 { 31 /** Red */ 32 if ($i < $colorLevels[0]) 33 { 34 $colors[$i][0] = CLICKHEAT_GREY_COLOR + (CLICKHEAT_LOW_COLOR - CLICKHEAT_GREY_COLOR) * $i / $colorLevels[0]; 35 } 36 elseif ($i < $colorLevels[2]) 37 { 38 $colors[$i][0] = CLICKHEAT_LOW_COLOR; 39 } 40 elseif ($i < $colorLevels[3]) 41 { 42 $colors[$i][0] = CLICKHEAT_LOW_COLOR + (CLICKHEAT_HIGH_COLOR - CLICKHEAT_LOW_COLOR) * ($i - $colorLevels[2]) / ($colorLevels[3] - $colorLevels[2]); 43 } 44 else 45 { 46 $colors[$i][0] = CLICKHEAT_HIGH_COLOR; 47 } 48 /** Green */ 49 if ($i < $colorLevels[0]) 50 { 51 $colors[$i][1] = CLICKHEAT_GREY_COLOR + (CLICKHEAT_LOW_COLOR - CLICKHEAT_GREY_COLOR) * $i / $colorLevels[0]; 52 } 53 elseif ($i < $colorLevels[1]) 54 { 55 $colors[$i][1] = CLICKHEAT_LOW_COLOR + (CLICKHEAT_HIGH_COLOR - CLICKHEAT_LOW_COLOR) * ($i - $colorLevels[0]) / ($colorLevels[1] - $colorLevels[0]); 56 } 57 elseif ($i < $colorLevels[3]) 58 { 59 $colors[$i][1] = CLICKHEAT_HIGH_COLOR; 60 } 61 else 62 { 63 $colors[$i][1] = CLICKHEAT_HIGH_COLOR - (CLICKHEAT_HIGH_COLOR - CLICKHEAT_LOW_COLOR) * ($i - $colorLevels[3]) / (127 - $colorLevels[3]); 64 } 65 /** Blue */ 66 if ($i < $colorLevels[0]) 67 { 68 $colors[$i][2] = CLICKHEAT_GREY_COLOR + (CLICKHEAT_HIGH_COLOR - CLICKHEAT_GREY_COLOR) * $i / $colorLevels[0]; 69 } 70 elseif ($i < $colorLevels[1]) 71 { 72 $colors[$i][2] = CLICKHEAT_HIGH_COLOR; 73 } 74 elseif ($i < $colorLevels[2]) 75 { 76 $colors[$i][2] = CLICKHEAT_HIGH_COLOR - (CLICKHEAT_HIGH_COLOR - CLICKHEAT_LOW_COLOR) * ($i - $colorLevels[1]) / ($colorLevels[2] - $colorLevels[1]); 77 } 78 else 79 { 80 $colors[$i][2] = CLICKHEAT_LOW_COLOR; 81 } 82 } 83 84 $max = 35; 85 //$blur = imagecreatetruecolor(50, 50); 86 //$white = imagecolorallocate($blur, 255, 255, 255); 87 imagefill($img, 0, 0, $white); 88 /** 89 * Courbe en forme de poire (pear-like curve) 90 * http://www.mathcurve.com/courbes2d/piriforme/piriforme.shtml 91 **/ 92 for ($i = 1; $i <= $max; $i++) 93 { 94 $a = $max - $i + 1; 95 $b = $a * (2 - $i / $max); 96 $color = imagecolorallocate($img, $colors[ceil($i * 127 / $max)][0], $colors[ceil($i * 127 / $max)][1], $colors[ceil($i * 127 / $max)][2]); 97 for ($t = 0; $t < 360; $t++) 98 { 99 imagesetpixel($img, 8.5 + $a * $a / $b * cos($t) * cos($t) * cos($t) * sin($t), min($max - 1, $max - $a + $a * cos($t) * cos($t)), $color); 100 } 101 } 102 103 $string = 'ClickHeat'; 104 $x = 18; 105 $y = 32; 106 $font = '/mnt/win_dd/WINDOWS/Fonts/verdana.ttf'; 107 if (!file_exists($font)) 108 { 109 exit('Font not found'); 110 } 111 $size = 25; 112 for ($i = 0, $max = strlen($string); $i < $max; $i++) 113 { 114 $info = imagettfbbox($size, 0, $font, $string[$i]); 115 if (strtolower($string[$i]) === 'h') 116 { 117 $font = '/mnt/win_dd/WINDOWS/Fonts/verdanab.ttf'; 118 } 119 imagettftext($img, $size, 0, $x + 1, $y + 1, $shadow, $font, $string[$i]); 120 imagettftext($img, $size, 0, $x, $y, $blue, $font, $string[$i]); 121 $x += $info[2] - $info[0] + 3; 122 if (strtolower($string[$i]) === 'c' || strtolower($string[$i]) === 'k') 123 { 124 $x -= 2; 125 } 126 if (strtolower($string[$i]) === 'h') 127 { 128 $x += 4; 129 } 130 } 131 132 header('Content-Type: image/png'); 133 imagepng($img, './images/logo170.png'); 134 imagepng($img); 135 imagedestroy($img); 136 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 14:10:01 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |