PHP   发布时间:2022-04-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了PHP的图像箭头线需要光滑大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

我在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的图像箭头线需要光滑全部内容,希望文章能够帮你解决PHP的图像箭头线需要光滑所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: