douke7274 2013-05-09 23:36
浏览 140
已采纳

在PHP中的两点之间绘制一条曲线

I want to draw a simple curved line between two points. More specifically, the top left and bottom right corner of an image of arbitrary size.

I tried using imagearc, but apparently that's not what I'm looking for. To illustrate what I mean: curved line

I can't find any function to help me along, so any help would be appreciated :)

  • 写回答

3条回答 默认 最新

  • dpq755012465 2013-05-10 13:31
    关注

    I solved it using imagearc after all.

    The trick is to set the bottom left corner as the center, -90° start angle, 0° end angle and double the size of the image:

    //GET VARS
    $width = $_GET['width'];
    $height = $_GET['height'];
    
    //CREATE IMGS
    $image = imagecreatetruecolor($width, $height);
    $color = imagecolorallocate($image, 255, 0, 0);
    
    imagearc(    $image,
                 0, 0, //center point = bottom-left corner
                 $width*2, $height*2, //size = image size * 2
                 -90, //top left
                 0, //bottom right
                 $color);
    
    
    //OUTPUT IMAGE
    header('Content-Type: image/png');
    imagepng($image);
    
    //DESTROY IMAGE
    imagedestroy($image);
    

    Looks like this: http://www.schizosplayground.com/pers/curvedlinetest.php?width=132&height=163

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 pip install后修改模块路径,import失败,需要在哪里修改环境变量?
  • ¥15 爬取1-112页所有帖子的标题但是12页后要登录后才能 我使用selenium模拟登录 账号密码输入后 会报错 不知道怎么弄了
  • ¥30 关于用python写支付宝扫码付异步通知收不到的问题
  • ¥50 vue组件中无法正确接收并处理axios请求
  • ¥15 隐藏系统界面pdf的打印、下载按钮
  • ¥15 MATLAB联合adams仿真卡死如何解决(代码模型无问题)
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决
  • ¥15 python中transformers可以正常下载,但是没有办法使用pipeline
  • ¥50 分布式追踪trace异常问题