Exemple #1
0
 /**
  * Function: drawLine
  *
  * Draws the given line.
  */
 function drawLine($x0, $y0, $x1, $y1, $stroke = null, $dashed = false)
 {
     $stroke = $this->getColor($stroke, "black");
     if ($dashed) {
         // ImageDashedLine only works for vertical lines and
         // ImageSetStyle doesnt work with antialiasing.
         if ($this->antialias && function_exists("imageantialias")) {
             imageantialias($this->image, false);
         }
         $st = array($stroke, $stroke, $stroke, $stroke, IMG_COLOR_TRANSPARENT, IMG_COLOR_TRANSPARENT, IMG_COLOR_TRANSPARENT, IMG_COLOR_TRANSPARENT);
         imageSetStyle($this->image, $st);
         imageLine($this->image, $x0, $y0, $x1, $y1, IMG_COLOR_STYLED);
         if ($this->antialias && function_exists("imageantialias")) {
             imageantialias($this->image, true);
         }
     } else {
         imageLine($this->image, $x0, $y0, $x1, $y1, $stroke);
     }
 }
Exemple #2
0
<?php

## Изменение пера.
// Создаем новое изображение.
$im = imageCreate(100, 100);
$w = imageColorAllocate($im, 255, 255, 255);
$c1 = imageColorAllocate($im, 0, 0, 255);
$c2 = imageColorAllocate($im, 0, 255, 0);
// Очищаем фон.
imageFilledRectangle($im, 0, 0, imageSX($im), imageSY($im), $w);
// Устанавливаем стиль пера.
$style = array($c2, $c2, $c2, $c2, $c2, $c2, $c2, $c1, $c1, $c1, $c1);
imageSetStyle($im, $style);
// Устанавливаем толщину пера.
imageSetThickness($im, 2);
// Рисуем линию.
imageLine($im, 0, 0, 100, 100, IMG_COLOR_STYLED);
// Выводим изображение в браузер.
header("Content-type: image/png");
imagePng($im);
?>