Re: Fw: WELCOME to php-gtk-general@lists.php.net
| From: | cohort | Date: | Mon, 14 Aug 2006 19:52:25 +0000 |
| Subject: | Re: Fw: WELCOME to php-gtk-general@lists.php.net | ||
| References: | 1 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-7093@lists.php.net to get a copy of this message | ||
thomas favennec wrote:
> is someone knowing " max-width / min-with " function, or way to do
> that in phpgtk2 ?
Do you mean something like this?
-=-
// list ($sx, $sy) = aspectScale ($bx, $by, $ix, $iy);
function aspectScale ($bx, $by, $ix, $iy)
{
if ($ix > $iy) {
// fit to width
$scale = $bx / $ix;
$sy = $scale * $iy;
if ($sy > $by) {
// If it doesn't fit, go the other way
$scale = $by / $iy;
$sx = $scale * $ix;
$sy = $by;
} else {
$sx = $bx;
}
} else {
// fit to height
$scale = $by / $iy;
$sx = $scale * $ix;
if ($sx > $bx) {
$scale = $bx / $ix;
$sx = $bx;
$sy = $scale * $iy;
} else {
$sy = $by;
}
}
return array($sx, $sy);
}
-=-