php图像箭头线需要平滑

标签 php image image-processing gd line

我在 php 中制作了一条线,到目前为止它显示良好,但我现在遇到的问题是这条线不平滑,它显示为断边。以下是制作半径线的代码:

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);


}

以下是指南针示例,我在上面画线。

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

最佳答案

我自己还没有在 GD 中尝试抗锯齿,但它似乎在那里......

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

关于php图像箭头线需要平滑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2307264/

相关文章:

html - 图像旁边的多行文本 (CSS-HTML)

python - 创建自定义数据集

image-processing - 为什么傅里叶变换可以用于图像识别同时对噪声敏感?

php - CodeIgniter 选择查询日期差异

php - 无法获取缓存的 Kerberos 票证

php - Web应用的瓶颈?

c++ - 灰度图像到单色度?

ios - 使用手势将图像从 UIWebView 保存到相机胶卷

image - 使用openCV在图像中实现SIFT

php - 流明:一对多插入数据时违反外键约束