>
> *scaleTo: anExtent*
>   "Return a Point scalefactor for shrinking a thumbnail of the receiver's
> extent to fit within anExtent."


5@5 scaleTo: 10@10 *=> 2.0@2.0*
10@10 scaleTo: 5@5 *=> 0.5@0.5*

10@10 scaleTo: 5@10 *=> 1.0@1.0 (wat)*
5@10 scaleTo: 10@0 *=> **0.6666666666666666@0.0 (wat?)*
5@0 scaleTo: 10@0 *=> ZeroDivide (still, wat?)*

The idea of the method is nice, especially result as float point, so it can
be nicely used for UI. I just don't understand why by contract it does not
work with zeros.

Imagine we have two UI elements of arbitrary extent, meaning that 5@0 is
completely valid extent. Then imagine we have another UI element with
extent 10@0. I would expect to have at least any valid scaling factor that
would give correct result if applied.

For example for corner cases result could be:

5@10 scaleTo: 10@0 => 2.0@0.0 (to scale 10 to 0 we need to multiply by 0)
5@0 scaleTo: 10@10 => ZeroDivide
5@0 scaleTo: 10@0 => 2.0@1.0 (when scaling factor is 1.0 it means that
scaled arguments are equal, so the same rule can be applied when scaling 0
to 0. Please realize, scaling is not a division!)

Otherwise this method is completely useless (no senders, btw)
*So, let's discuss. :)*

Cheers,
Alex

Reply via email to