Blame view

libs/fonts/index.php 1.13 KB
42868d70   andryeyev   Создал GIT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  <?php
       //print $_SERVER['DOCUMENT_ROOT'];
             $ttf = "{$_SERVER['DOCUMENT_ROOT']}/fonts/timeset.ttf";
  if (!file_exists($ttf))exit;
  
  
  $img = imagecreate(120,30);
  $colorGrey=imagecolorallocate($img, 192, 192, 192);
  $black = imagecolorallocate($img,0,0,0);
  $white = imagecolorallocate($img,255,255,255);
  imagefill($img,0,0,$white);
  $n[] = rand(0,9);
  $n[] = rand(0,9);
  $n[] = rand(0,9);
  $n[] = rand(0,9);
  $_SESSION['spam'] = implode('',$n);
  $home=getenv("DOCUMENT_ROOT");
  imagettftext($img,20,0,9,25,$black,$ttf,implode(' ',$n));
  //imageline($img, 0, 0, 0, 150, $black);
  //imageline($img, 0, 0, 150, 0, $black);
  //imageline($img, 60, 60, 60, 60, $black);
  $p = 0;
  while ($p<1000)
  {
     $x = mt_rand(1,149); // ñëó÷àéíàÿ êîîðäèíàòà ïèêñåëÿ øóìà ïî îñè X
     $y = mt_rand(1,59); // îñü Y
     $pixel = imagecolorat($img,$x,$y); // óçíàåì êàêîé öâåò èñïîëüçóåòñÿ íà ìåñòå áóäóùåãî ïèêñåëÿ øóìà
     $point = ($pixel == $black) ? $white : $black; // åñëè áûë ÷åðíûé, êðàñèì ïèêñåëü áåëûì, åñëè áåëûé - êðàñèì ÷åðíûì
     imagesetpixel($img,$x,$y,$point); // ðèñóåì ñàì ïèêñåëü
     $p++;
  }
  imagepng($img);
  imagedestroy($img);
  header('Content-Type: image/png');
  ?>