Вход Регистрация
* TRUEтень

Градент текст

  1. function str2gradient($text,$from='', $to='', $mode="hex")
  2. {
  3. if($mode=="hex")
  4. {
  5. $to = hexdec($to[0].$to[1]).",".hexdec($to[2].$to[3]).",".hexdec($to[4].$to[5]);
  6. $from = hexdec($from[0].$from[1]).",".hexdec($from[2].$from[3]).",".hexdec($from[4].$from[5]);
  7. }
  8.  
  9. if( empty($text) )
  10. return '';
  11. else
  12. $levels=strlen($text);
  13.  
  14. if (empty($from))
  15. $from = array(0,0,255);
  16. else
  17. $from = explode(",", $from);
  18.  
  19. if (empty($to))
  20.  
  21. $to = array(255,0,0);
  22. else
  23. $to = explode(",", $to);
  24.  
  25. $output = "";
  26.  
  27. for ($i=1;$i<=$levels;$i++)
  28. {
  29. for ($ii=0;$ii<4;$ii++)
  30. {
  31.  
  32. $tmp[$ii] = $from[$ii] - $to[$ii];
  33. $tmp[$ii] = floor($tmp[$ii] / $levels);
  34. $rgb[$ii] = $from[$ii] -($tmp[$ii] * $i);
  35.  
  36. if ($rgb[$ii] > 255) $rgb[$ii] = 255;
  37.  
  38. $rgb[$ii] = dechex($rgb[$ii]);
  39. $rgb[$ii] = strtoupper($rgb[$ii]);
  40.  
  41. if (strlen($rgb[$ii]) < 2) $rgb[$ii] = "0$rgb[$ii]";
  42. }
  43. $output .= "<font color="#".$rgb[0].$rgb[1].$rgb[2]."">" . $text[$i -1 ] . "</font>";
  44. }
  45. return $output."n";
  46. }
  47. echo str2gradient("Привет, я Градиент!", "f11717", "21f117");
» Описание: Пример градиент текста.
» Время добавления: 19 Дек 2014 в 09:26
» Посмотров: 1266
» textarea
» Рейтинг: [+1 | -0]
Комментарии [0]
Онлайн: 2
Реклама