略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: PDF_lineto

2024-11-15

PDF_lineto

(PHP 4, PECL pdflib >= 1.0.0)

PDF_linetoDraw a line

说明

PDF_lineto ( resource $p , float $x , float $y ) : bool

Draws a line from the current point to another point. 成功时返回 TRUE, 或者在失败时返回 FALSE

add a note add a note

User Contributed Notes 2 notes

up
-1
rod-php at thecomplex dot com
16 years ago
function find_angle ($x1, $y1, $x2, $y2) {
// This function takes two points (x1,y1) and (x2,y2)
// as inputs and finds the slope and angle of a line
// between those two points.  It returns the angle
// and slope in an array. I can't figure out how to
// return a NULL value, so if the two input points
// are in a vertical line, the function returns
// $angle = 90 and $slope = 0. I know this is wrong.
        if (($x2-$x1) != 0) {
                $slope = ($y2-$y1)/($x2-$x1);
                // Get rotation angle by finding the arctangent of the slope
                $angle = rad2deg(atan($slope));
                if ($x1 > $x2) {
                        $angle = 180+$angle;
                } elseif ($y1 > $y2) {
                        $angle = 360+$angle;
                }
        } else {
                // Vertical line has no slope, 90deg angle
                $angle = 90;
#               unset ($slope);
                $slope = 0;
        }
        return array ($angle, $slope);
}
up
-1
rod-php at thecomplex dot com
16 years ago
function find_length ($x1, $y1, $x2, $y2) {
// Find distance between two points (x1,y1) and (x2,y2)
// Also useful to find length of a line.
        return sqrt( pow($x2-$x1,2) + pow($y2-$y1,2) );
}

官方地址:https://www.php.net/manual/en/function.pdf-lineto.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3