[ Index ]
 

Code source de phpMyVisites 2.3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/plugins/clickheat/libs/ -> logo.png.php (source)

   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_LOW_COLOR', 0);
  10  define('CLICKHEAT_HIGH_COLOR', 190);
  11  
  12  /** Image creation */
  13  $img = imagecreatetruecolor(80, 15);
  14  $white = imagecolorallocate($img, 255, 255, 255);
  15  $grey = imagecolorallocate($img, 120, 120, 120);
  16  $black = imagecolorallocate($img, 0, 0, 0);
  17  
  18  /** Colors creation : deep blue (rgB) => light blue (rGB) => green (rGb) => yellow (RGb) => red (Rgb), 20 colors between each of these */
  19  for ($i = 0; $i < 80; $i++)
  20  {
  21      /** Red */
  22      if ($i < 40)
  23      {
  24          $red = CLICKHEAT_LOW_COLOR;
  25      }
  26      elseif ($i < 60)
  27      {
  28          $red = CLICKHEAT_LOW_COLOR + (CLICKHEAT_HIGH_COLOR - CLICKHEAT_LOW_COLOR) * ($i - 40) / 20;
  29      }
  30      else
  31      {
  32          $red = CLICKHEAT_HIGH_COLOR;
  33      }
  34      /** Green */
  35      if ($i < 20)
  36      {
  37          $green = CLICKHEAT_LOW_COLOR + (CLICKHEAT_HIGH_COLOR - CLICKHEAT_LOW_COLOR) * $i / 20;
  38      }
  39      elseif ($i < 60)
  40      {
  41          $green = CLICKHEAT_HIGH_COLOR;
  42      }
  43      else
  44      {
  45          $green = CLICKHEAT_HIGH_COLOR - (CLICKHEAT_HIGH_COLOR - CLICKHEAT_LOW_COLOR) * ($i - 60) / 20;
  46      }
  47      /** Blue */
  48      if ($i < 20)
  49      {
  50          $blue = CLICKHEAT_HIGH_COLOR;
  51      }
  52      elseif ($i < 40)
  53      {
  54          $blue = CLICKHEAT_HIGH_COLOR - (CLICKHEAT_HIGH_COLOR - CLICKHEAT_LOW_COLOR) * ($i - 20) / 20;
  55      }
  56      else
  57      {
  58          $blue = CLICKHEAT_LOW_COLOR;
  59      }
  60      $colors[$i] = imagecolorallocate($img, ceil($red), ceil($green), ceil($blue));
  61  }
  62  
  63  /** Rainbow */
  64  for ($i = 0; $i < 80; $i += 2)
  65  {
  66      imageline($img, $i/2, 0, $i/2, 15, $colors[0]);
  67      imageline($img, $i/2 + 40, 0, $i/2 + 40, 15, $colors[$i]);
  68  }
  69  imagerectangle($img, 0, 0, 79, 14, $grey);
  70  $pixels = array(
  71  '                                                                                ',
  72  ' ############################################################################## ',
  73  ' #                                                                            # ',
  74  ' #                                                                            # ',
  75  ' #                                                                            # ',
  76  ' #      ##     #      #     ##     #  #        #  #    ###     ##     ###     # ',
  77  ' #     #  #    #      #    #  #    # #         #  #    #      #  #     #      # ',
  78  ' #     #       #      #    #       ##          ####    ##     ####     #      # ',
  79  ' #     #  #    #      #    #  #    # #         #  #    #      #  #     #      # ',
  80  ' #      ##     ###    #     ##     #  #        #  #    ###    #  #     #      # ',
  81  ' #                                                                            # ',
  82  ' #                                                                            # ',
  83  ' #                                                                            # ',
  84  ' ############################################################################## ',
  85  '                                                                                ');
  86  for ($x = 0; $x < 80; $x++)
  87  {
  88      for ($y = 0; $y < 15; $y++)
  89      {
  90          if ($pixels[$y][$x] === '#')
  91          {
  92              imagesetpixel($img, $x, $y, $white);
  93          }
  94      }
  95  }
  96  header('Content-Type: image/png');
  97  imagepng($img, './images/logo.png');
  98  imagepng($img);
  99  imagedestroy($img);
 100  ?>


Généré le : Mon Nov 26 14:10:01 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics