在php imageftbbox中,文本的边框有什么应用?
manual的例子中,它被用来确定IGFEFTEXT函数的坐标。有必要吗?也许我在这里遗漏了什么。

...

// First we create our bounding box
$bbox = imageftbbox(10, 0, $font, 'The PHP Documentation Group');

// This is our cordinates for X and Y
$x = $bbox[0] + (imagesx($im) / 2) - ($bbox[4] / 2) - 5;
$y = $bbox[1] + (imagesy($im) / 2) - ($bbox[5] / 2) - 5;

imagefttext($im, 10, 0, $x, $y, $black, $font, 'The PHP Documentation Group');

...

最佳答案

Flylib有大量关于imagettfbox()的信息。
以下是链接信息中的一些相关信息:
(图片版权Flylib)
从上面的图片,你可以看到有4点8信息(如文件已经说明):

Array information     Bounding box coordinate
===================================================================
    0                 X coordinate of the lower left hand corner
    1                 Y coordinate of the lower left hand corner
    2                 X coordinate of the lower right hand corner
    3                 Y coordinate of the lower right hand corner
    4                 X coordinate of the upper right hand corner
    5                 Y coordinate of the upper right hand corner
    6                 X coordinate of the upper left hand corner
    7                 Y coordinate of the upper left hand corner

同样,如文档所述,无论角度如何,此信息都是相对于文本的。因此,如果将文本顺时针旋转90度,则边界框将变为:
Array information     Bounding box coordinate
===================================================================
    0                 X coordinate of the upper left hand corner
    1                 Y coordinate of the upper left hand corner
    2                 X coordinate of the lower left hand corner
    3                 Y coordinate of the lower left hand corner
    4                 X coordinate of the lower right hand corner
    5                 Y coordinate of the lower right hand corner
    6                 X coordinate of the upper right hand corner
    7                 Y coordinate of the upper right hand corner

我相信另一个资源可以帮助您更好地理解包围盒的基本思想:
http://ruquay.com/sandbox/imagettf/

07-28 07:33