2016-03-04 11:48 GMT+01:00 Aliaksei Syrel <[email protected]>:

> *scaleTo: anExtent*
>>   "Return a Point scalefactor for shrinking a thumbnail of the
>> receiver's extent to fit within anExtent."
>
>
> 5@5 scaleTo: 10@10 *=> [email protected]*
> 10@10 scaleTo: 5@5 *=> [email protected]*
>
> 10@10 scaleTo: 5@10 *=> [email protected] (wat)*
> 5@10 scaleTo: 10@0 *=> **[email protected] (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 => [email protected] (to scale 10 to 0 we need to multiply by 0)
> 5@0 scaleTo: 10@10 => ZeroDivide
> 5@0 scaleTo: 10@0 => [email protected] (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!)
>

As it scales to fit with preserving the aspect ration, I would expect:


5@10 scaleTo: 10@0 => Some error, as an extent with aspect ratio 1/2 can
not fit in something with zero height.
5@0 scaleTo: 10@10 => Although it is a bit strange, I would expect 2@0
5@0 scaleTo: 10@0 => Again, 2@0 would work, it scales an 5@0 extent to fit
in 10@0



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

Reply via email to