public function getBoundingBox($padding = 10)
    {
        $bare = imageftbbox(
                $this->getFontSize()
                , 0
                , $this->getFont()
                , $this->getString()
                , array('linespacing' => $this->getLineSpacing())
        );

        $a = deg2rad($this->getAngle());
        $ca = cos($a);
        $sa = sin($a);
        $rect = array();
        for ($i = 0; $i < 7; $i += 2) {
            $rect[$i] = round($bare[$i] * $ca + $bare[$i + 1] * $sa);
            $rect[$i + 1] = round($bare[$i + 1] * $ca - $bare[$i] * $sa);
        }

        $minX = min(array($rect[0], $rect[2], $rect[4], $rect[6]));
        $maxX = max(array($rect[0], $rect[2], $rect[4], $rect[6]));
        $minY = min(array($rect[1], $rect[3], $rect[5], $rect[7]));
        $maxY = max(array($rect[1], $rect[3], $rect[5], $rect[7]));

        $dx = $this->getCoordinate()->getX() - abs($minX) - 1;
        $dy = $this->getCoordinate()->getY() - abs($minY) - 1 + $this->getFontSize();

        $width = $maxX - $minX;
        $height = $maxY - $minY;

        $padding = (int) $padding;
        $dimension = new Dimension(
                $width + 2 + ($padding * 2)
                , $height + 2 + ($padding * 2)
        );
        $coordinate = new Coordinate(
                $dx - $padding
                , $dy - $padding
        );

        return new Box($dimension, $coordinate);
    }
public function getBoundingBox($padding = 10)
    {
        $bare = imageftbbox(
                $this->getFontSize()
                , 0
                , $this->getFont()
                , $this->getString()
                , array('linespacing' => $this->getLineSpacing())
        );

        $a = deg2rad($this->getAngle());
        $ca = cos($a);
        $sa = sin($a);
        $rect = array();
        for ($i = 0; $i < 7; $i += 2) {
            $rect[$i] = round($bare[$i] * $ca + $bare[$i + 1] * $sa);
            $rect[$i + 1] = round($bare[$i + 1] * $ca - $bare[$i] * $sa);
        }

        $minX = min(array($rect[0], $rect[2], $rect[4], $rect[6]));
        $maxX = max(array($rect[0], $rect[2], $rect[4], $rect[6]));
        $minY = min(array($rect[1], $rect[3], $rect[5], $rect[7]));
        $maxY = max(array($rect[1], $rect[3], $rect[5], $rect[7]));

        $dx = $this->getCoordinate()->getX() - abs($minX) - 1;
        $dy = $this->getCoordinate()->getY() - abs($minY) - 1 + $this->getFontSize();

        $width = $maxX - $minX;
        $height = $maxY - $minY;

        $padding = (int) $padding;
        $dimension = new Dimension(
                $width + 2 + ($padding * 2)
                , $height + 2 + ($padding * 2)
        );
        $coordinate = new Coordinate(
                $dx - $padding
                , $dy - $padding
        );

        return new Box($dimension, $coordinate);
    }
public function getBoundingBox ( $ padding = 10 ) { $ bare = imageftbbox ( $ this -> getFontSize ( ) , 0 , $ this -> getFont ( ) , $ this -> getString ( ) , array ( 'linespacing' => $ this -> getLineSpacing ( ) ) ) ; $ a = deg2rad ( $ this -> getAngle ( ) ) ; $ ca = cos ( $ a ) ; $ sa = sin ( $ a ) ; $ rect = array ( ) ; for ( $ i = 0 ; $ i < 7 ; $ i += 2 ) { $ rect [ $ i ] = round ( $ bare [ $ i ] * $ ca + $ bare [ $ i + 1 ] * $ sa ) ; $ rect [ $ i + 1 ] = round ( $ bare [ $ i + 1 ] * $ ca - $ bare [ $ i ] * $ sa ) ; } $ minX = min ( array ( $ rect [ 0 ] , $ rect [ 2 ] , $ rect [ 4 ] , $ rect [ 6 ] ) ) ; $ maxX = max ( array ( $ rect [ 0 ] , $ rect [ 2 ] , $ rect [ 4 ] , $ rect [ 6 ] ) ) ; $ minY = min ( array ( $ rect [ 1 ] , $ rect [ 3 ] , $ rect [ 5 ] , $ rect [ 7 ] ) ) ; $ maxY = max ( array ( $ rect [ 1 ] , $ rect [ 3 ] , $ rect [ 5 ] , $ rect [ 7 ] ) ) ; $ dx = $ this -> getCoordinate ( ) -> getX ( ) - abs ( $ minX ) - 1 ; $ dy = $ this -> getCoordinate ( ) -> getY ( ) - abs ( $ minY ) - 1 + $ this -> getFontSize ( ) ; $ width = $ maxX - $ minX ; $ height = $ maxY - $ minY ; $ padding = ( int ) $ padding ; $ dimension = new Dimension ( $ width + 2 + ( $ padding * 2 ) , $ height + 2 + ( $ padding * 2 ) ) ; $ coordinate = new Coordinate ( $ dx - $ padding , $ dy - $ padding ) ; return new Box ( $ dimension , $ coordinate ) ; }
Get bouding box for the current text object

@param integer $padding text padding

@return \Jaguar\Box
Get bouding box for the current text object