Example #1
0
function skyview($im, $sz, $C)
{
    $a = 90;
    $a = $sz * 0.95 * ($a / 180);
    imageFilledArc($im, $sz / 2, $sz / 2, $a * 2, $a * 2, 0, 360, $C['mdgray'], 0);
    imageArc($im, $sz / 2, $sz / 2, $a * 2, $a * 2, 0, 360, $C['black']);
    $x = $sz / 2 - 16;
    $y = $sz / 2 - $a;
    imageString($im, 2, $x, $y, "0", $C['ltgray']);
    $a = 85;
    $a = $sz * 0.95 * ($a / 180);
    imageFilledArc($im, $sz / 2, $sz / 2, $a * 2, $a * 2, 0, 360, $C['white'], 0);
    imageArc($im, $sz / 2, $sz / 2, $a * 2, $a * 2, 0, 360, $C['ltgray']);
    imageString($im, 1, $sz / 2 - 6, $sz + $a, '5', $C['black']);
    $x = $sz / 2 - 16;
    $y = $sz / 2 - $a;
    imageString($im, 2, $x, $y, "5", $C['ltgray']);
    skygrid($im, $sz, $C);
    $x = $sz / 2 - 16;
    $y = $sz / 2 - 8;
    /* imageString($im, 2, $x, $y, "90", $C['ltgray']); */
    imageString($im, 4, $sz / 2 + 4, 2, 'N', $C['black']);
    imageString($im, 4, $sz / 2 + 4, $sz - 16, 'S', $C['black']);
    imageString($im, 4, 4, $sz / 2 + 4, 'E', $C['black']);
    imageString($im, 4, $sz - 10, $sz / 2 + 4, 'W', $C['black']);
}
Example #2
0
// отключить antialias и проверить
imageline($image, 80, 50, 20, 280, $red);
// отключить antialias и проверить
// 11. Незалитый прямоугольник
imagerectangle($image, 20, 50, 80, 280, $blue);
// 12. Залитый прямоугольник
//imagefilledrectangle($image, 20, 50, 80, 280, $blue);
// 13. Многоугольник
$points = array(0, 0, 100, 200, 300, 200, 200, 100);
imagepolygon($image, $points, 4, $gray);
//imagefilledpolygon($image, $points, 4, $gray);
// 14. Эллипс
imageellipse($image, 200, 150, 300, 200, $red);
//imagefilledellipse($image, 200, 140, 300, 200, $red);
// 15. Дуга
imageArc($image, 210, 160, 300, 200, 0, 90, $black);
imagefilledarc($image, 230, 160, 300, 200, 0, 35, $gray, IMG_ARC_PIE);
imagefilledarc($image, 230, 160, 300, 200, 45, 90, $red, IMG_ARC_CHORD);
imagefilledarc($image, 230, 160, 300, 200, 100, 135, $blue, IMG_ARC_EDGED);
imagefilledarc($image, 230, 160, 300, 200, 150, 210, $blue, IMG_ARC_ROUNDED);
imagefilledarc($image, 230, 160, 300, 200, 200, 230, $blue, IMG_ARC_NOFILL);
// 16. Текст
imagestring($image, 5, 350, 100, 'PHP5', $black);
// водяной знак
imagechar($image, 4, 350, 120, 'PHP5', $black);
imagecharup($image, 4, 350, 80, 'PHP5', $black);
// ресурс, шрифт, градус, x, y, цвет, файл со шрифтом, текст
imagettftext($image, 30, 10, 300, 150, $red, 'arialn.ttf', 'PHP5');
// 16. Загрузка картинки
//$im = imagecreatefromgif('test.gif');
// 17. Установка толщины
Example #3
0
 /**
  * Function: drawActor
  *
  * Draws then given cloud.
  */
 function drawActor($x, $y, $w, $h, $fill = null, $stroke = null, $shadow = false)
 {
     if (isset($fill)) {
         if ($shadow) {
             $dx = mxConstants::$SHADOW_OFFSETX;
             $dy = mxConstants::$SHADOW_OFFSETY;
             imageFilledEllipse($this->image, $x + 0.5 * $w + $dx, $y + 0.2 * $h + $dy, 0.4 * $w, 0.4 * $h, $this->shadowColor);
             imageFilledEllipse($this->image, $x + 0.2 * $w + $dx, $y + 0.6 * $h + $dy, 0.4 * $w, 0.4 * $h, $this->shadowColor);
             imageFilledEllipse($this->image, $x + 0.8 * $w + $dx, $y + 0.6 * $h + $dy, 0.4 * $w, 0.4 * $h, $this->shadowColor);
             imageFilledRectangle($this->image, $x + 0.2 * $w + $dx, $y + 0.4 * $h + $dy, $x + 0.8 * $w + $dx, $y + 0.6 * $h + $dy, $this->shadowColor);
             imageFilledRectangle($this->image, $x + $dx, $y + 0.6 * $h + $dy, $x + $w + $dx, $y + $h + $dy, $this->shadowColor);
         }
         $fill = $this->getColor($fill);
         imageFilledEllipse($this->image, $x + 0.5 * $w, $y + 0.2 * $h, 0.4 * $w, 0.4 * $h, $fill);
         imageFilledEllipse($this->image, $x + 0.2 * $w, $y + 0.6 * $h, 0.4 * $w, 0.4 * $h, $fill);
         imageFilledEllipse($this->image, $x + 0.8 * $w, $y + 0.6 * $h, 0.4 * $w, 0.4 * $h, $fill);
         imageFilledRectangle($this->image, $x + 0.2 * $w, $y + 0.4 * $h, $x + 0.8 * $w, $y + 0.6 * $h, $fill);
         imageFilledRectangle($this->image, $x, $y + 0.6 * $h, $x + $w, $y + $h, $fill);
     }
     if ($stroke != null) {
         $stroke = $this->getColor($stroke);
         imageEllipse($this->image, $x + 0.5 * $w, $y + 0.2 * $h, 0.4 * $w, 0.4 * $h, $stroke);
         imageLine($this->image, $x + 0.2 * $w, $y + 0.4 * $h, $x + 0.8 * $w, $y + 0.4 * $h, $stroke);
         imageArc($this->image, $x + 0.2 * $w, $y + 0.6 * $h, 0.4 * $w, 0.4 * $h, 180, 270, $stroke);
         imageArc($this->image, $x + 0.8 * $w, $y + 0.6 * $h, 0.4 * $w, 0.4 * $h, 270, 360, $stroke);
         imageLine($this->image, $x, $y + 0.6 * $h, $x, $y + $h, $stroke);
         imageLine($this->image, $x, $y + $h, $x + $w, $y + $h, $stroke);
         imageLine($this->image, $x + $w, $y + $h, $x + $w, $y + 0.6 * $h, $stroke);
     }
 }
Example #4
0
 /**
  * Draws a arc  of a circle on the image
  * @param Point $center Point of the circles center
  * @param Dimension $dimension Dimension of the circle
  * @param integer $angleStart 0° is at 3 o'clock and the arc is drawn clockwise
  * @param integer $angleStop
  * @param Color $color
  * @return null
  */
 public function drawArc(Point $center, Dimension $dimension, $angleStart, $angleStop, Color $color)
 {
     $color = $this->allocateColor($color);
     $x = $center->getX();
     $y = $center->getY();
     $width = $dimension->getWidth();
     $height = $dimension->getHeight();
     imageArc($this->resource, $x, $y, $width, $height, $angleStart, $angleStop, $color);
 }
Example #5
0
    $lines[$l]["x2"] = mt_rand(0, imageSX($image));
    $lines[$l]["y2"] = mt_rand(0, imageSY($image));
    $lines[$l]["color"] = imagecolorallocate($image, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
    imageSetThickness($image, mt_rand(1, 3));
    imageLine($image, $lines[$l]["x1"], $lines[$l]["y1"], $lines[$l]["x2"], $lines[$l]["y2"], $lines[$l]["color"]);
}
for ($a = 0; $a < 7; $a++) {
    $arcs[$a]["x"] = mt_rand(0, imageSX($image));
    $arcs[$a]["y"] = mt_rand(0, imageSY($image));
    $arcs[$a]["width"] = mt_rand(0, imageSX($image));
    $arcs[$a]["height"] = mt_rand(0, imageSY($image));
    $arcs[$a]["u1"] = mt_rand(0, 360);
    $arcs[$a]["u2"] = mt_rand(0, 360);
    $arcs[$a]["color"] = imagecolorallocate($image, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
    imageSetThickness($image, mt_rand(1, 3));
    imageArc($image, $arcs[$a]["x"], $arcs[$a]["y"], $arcs[$a]["width"], $arcs[$a]["height"], $arcs[$a]["u1"], $arcs[$a]["u2"], $arcs[$a]["color"]);
}
for ($p = 0; $p < 999; $p++) {
    $x = mt_rand(0, imageSX($image));
    $y = mt_rand(0, imageSY($image));
    $color = imagecolorallocate($image, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
    imageSetPixel($image, $x, $y, $color);
}
for ($s = 0; $s < 5; $s++) {
    $letters[$s]["size"] = mt_rand(25, 35);
    $letters[$s]["corner"] = mt_rand(-20, 20);
    if ($s === 0) {
        $letters[$s]["x"] = 10;
    } else {
        $letters[$s]["x"] = $s * 35;
    }
 public function buildHead()
 {
     imageArc($this->img, 150, 75, 50, 50, 0, 360, 200);
 }
Example #7
0
$color = imageColorAllocate($i, 0, 255, 0);
imageFilledRectangle($i, 0, 0, imageSX($i), imageSY($i), $color);
//Функция imageFilledRectangle() - рисование закрашенного прямоугольника (1-ресурс изображения, 2 - х-координата точки 1, 3 - у-координата точки 1, 4 - х-координата точки 2, 5 - у-координата точки 2, 6 - цвет заливки)
$color = imageColorAllocate($i, 255, 0, 0);
imageRectangle($i, 100, 100, 200, 200, $color);
//Функция imageRectangle() - рисование прямоугольника (1-ресурс изображения, 2 - х-координата точки 1, 3 - у-координата точки 1, 4 - х-координата точки 2, 5 - у-координата точки 2, 6 - цвет бордера)
imageSetThickness($i, 10);
//Функция imageSetThickness() - задает толщину линии(1-ресурс изображения, 2-толщина линии)
$color = imageColorAllocate($i, 0, 0, 255);
imageRectangle($i, 50, 80, 150, 150, $color);
imageSetThickness($i, 3);
$color = imageColorAllocate($i, 255, 255, 0);
imageLine($i, 10, 10, 350, 250, $color);
//Функция imageLine() - рисует линию по двум точкам (1-ресурс изображения, 2 - х-координата точки 1, 3 - у-координата точки 1, 4 - х-координата точки 2, 5 - у-координата точки 2, 6 - цвет бордера)
$color = imageColorAllocate($i, 255, 255, 255);
imageArc($i, 300, 100, 150, 150, 0, 0, $color);
//Функция imagearc() - рисует окружность дуги с заданными координатами центра, дуга рисуется по часовой стрелке (1-ресурс изображения, 2 - х-координата центра, 3 - у-координата центра, 4 - ширина дуги, 5 - высота дуги, 6 - угол начала дуги в градусах, 7 - угол окончания дуги в градусах, 8 - цвет дуги )
//Функция imagefilledarc() - рисует и заливает окружность дуги с заданными координатами центра, дуга рисуется по часовой стрелке (1-ресурс изображения, 2 - х-координата центра, 3 - у-координата центра, 4 - ширина дуги, 5 - высота дуги, 6 - угол начала дуги в градусах, 7 - угол окончания дуги в градусах, 8 - цвет дуги )
$color = imageColorAllocate($i, 0, 255, 255);
imagefill($i, 130, 130, $color);
//Функция imagefill() - производит заливку, начиная с заданных координат точки (1-ресурс изображения, 2 - х-координата точки, 3 - у-координата точки, 4 - цвет заливки, либо можно указать константу заливки IMG_COLOR_TILED)
$im = imagecreatefromgif("images/image.gif");
imagesettile($i, $im);
//Функция imagesettile() - задает изображение, которое будет использовано в качестве элемента мозаичной заливки (1-ресурс изображения который будут заливать, 2- ресурс изображения для использования мозайчной заливки)
imagefill($i, 250, 50, IMG_COLOR_TILED);
$color = imagecolorallocate($i, 0, 0, 0);
imagepolygon($i, array(50, 250, 100, 250, 120, 280, 80, 350, 50, 250), 5, $color);
//Функция imagepolygon() - рисует многоугольник(1-ресурс изображения, 2 - массив координат вершин{array(x1,y1,x2,y2...)}, 3 - количество вершин точнее указанных точек, 4 - цвет бордера)
//Функция imagefilledpolygon() - рисует закрашенный многоугольник(1-ресурс изображения, 2 - массив координат вершин{array(x1,y1,x2,y2...)}, 3 - количество вершин точнее указанных точек, 4 - цвет заливки)
$color = imagecolorallocate($i, 128, 128, 128);
for ($iter = 0; $iter < 10000; $iter++) {
Example #8
0
 /**
  * @param $i
  * @param $color
  */
 public function makeImage(&$i, $color)
 {
     imageArc($i, $this->center[0], $this->center[1], $this->diam, $this->diam, 0, 360, $color);
 }