Php image arrow string should be smooth

im makes the line in php and while it is showing it is thin, but what problem im get now is that the line is not smooth, it shows as broken edges. Below is the code for creating a radius line:

function draw_radius($img, $x1, $y1, $radius, $angle, $arrow_color, $arrow_length = 10, $arrow_width = 3)
{
    $x2 = $x1 + $radius * cos(deg2rad($angle-90));
    $y2 = $y1 + $radius * sin(deg2rad($angle-90));
    imageline($img, $x1, $y1, $x2, $y2, $arrow_color);

    $distance = sqrt(pow($x1 - $x2, 2) + pow($y1 - $y2, 2));
    $dx = $x2 + ($x1 - $x2) * $arrow_length / $distance;
    $dy = $y2 + ($y1 - $y2) * $arrow_length / $distance;
    $k = $arrow_width / $arrow_length;
    $x2o = $x2 - $dx;
    $y2o = $dy - $y2;
    $x3 = $y2o * $k + $dx;
    $y3 = $x2o * $k + $dy;
    $x4 = $dx - $y2o * $k;
    $y4 = $dy - $x2o * $k;
    imageline($img, $x1, $y1, $dx, $dy, $arrow_color);
    imageline($img, $x3, $y3, $x4, $y4, $arrow_color);
    imageline($img, $x3, $y3, $x2, $y2, $arrow_color);
    imageline($img, $x2, $y2, $x4, $y4, $arrow_color);


}

The following is an example of a compass on which a drawing line is drawn.

compass example http://img246.imageshack.us/img246/6329/compassx.png

+3
source share
4 answers

I haven’t tried anti-aliasing in GD myself, but it seems there ...

http://uk.php.net/manual/en/function.imageantialias.php

+2
source

, . . : PHP .

+2

You can try this one , but following their example, it doesn't seem great. There are several other options you could try in the comments.

+1
source

cairo smooths well.

0
source

Source: https://habr.com/ru/post/1733792/


All Articles