size::fit_height PHP Method

fit_height() static public method

Fits width and height by a passed height and keeps the ratio
static public fit_height ( integer $width, integer $height, integer $fit, boolean $force = false ) : array
$width integer
$height integer
$fit integer The new height
$force boolean If width and height are smaller than the box this will force upscaling
return array An array with a key and value for width and height
    static function fit_height($width, $height, $fit, $force = false)
    {
        if ($height <= $fit && !$force) {
            return array('width' => $width, 'height' => $height);
        }
        $ratio = self::ratio($width, $height);
        return array('width' => floor($fit * $ratio), 'height' => $fit);
    }

Usage Example

Beispiel #1
0
 function fitHeight($height, $force = false)
 {
     $size = size::fit_height($this->width(), $this->height(), $height, $force);
     $this->info->width = $size['width'];
     $this->info->height = $size['height'];
     return $this;
 }
All Usage Examples Of size::fit_height