This is a translated page. The original can be found here: http://iwebdevel.com/2009/06/17/coding-dont-make-mistakes-when-resizing-objects-preserve-the-initial-ratio-correctly/
UPDATES VIA RSS | Email MISES A JOUR VIA RSS | Email Get updates via feedburner Get updates via twitter
Home / Coding / Coding: Don't make mis… Accueil / Codage / codage: Ne pas faire de mal ...

Coding: Don't make mistakes when resizing objects! Coding: Ne faites pas d'erreurs lors du redimensionnement des objets! Preserve the initial ratio correctly! Préserver le ratio initial correctement!

Posted on 17. Posté le 17. Jun, 2009 by Dragos in Coding Jun, 2009 par Dragos en codage

I was tempted many times to do quick adjustments to my code, without taking into consideration some basic mathematical principles. J'ai été tenté plusieurs fois de faire des ajustements rapides à mon code, sans tenir compte de certains principes mathématiques de base. For examples if a box is first of all 100px tall and 60px wide, and then I notice that this box does not fit the place where it was intended to be placed,  what I did was to subtract 10 px from the width of the box, for it to fit some area, and at the same time I subtracted 10 px from the height also, thinking that doing so I kept the ratio of the initial sizes of the box. Pour des exemples si une boîte est d'abord 100px de haut et 60px de large, et ensuite je m'aperçois que cette boîte ne convient pas à l'endroit où il était destiné à être placé, ce que j'ai fait était de soustraire 10 px partir de la largeur de la boîte, pour pour l'adapter à un domaine, et en même temps, j'ai soustrait 10 px de la hauteur aussi, en pensant que ce faisant, je maintient le ratio de la taille initiale de la boîte. In fact this is not true! En fait, ce n'est pas vrai!

Here's why: Voici pourquoi:

The ratio of the initial box is 100px/60px=1.66 Le ratio de la boîte initiale est 100px/60px = 1,66

In the second case the ratio is: (100px-10px)/(60px-10px)=1.8 Dans le second cas, le ratio est de: (100px-10px) / (60px, 10px) = 1.8

So, if you used to apply the same technique as I did to quickly resize objects, forget about it, as it's wrong! Donc, si vous avez utilisé pour appliquer la même technique que j'ai fait pour redimensionner rapidement des objets, oubliez-le, car c'est faux! Instead use the old method from school to determine a variable from two fractions, preserving the ratios. Au lieu de cela utiliser l'ancienne méthode de l'école afin de déterminer une variable à partir de deux fractions, de préserver les ratios. Back to the example above, in order to find out the new height value of the box I'd use this formula: 100px/60px=(100px-10px)/x, so x=60px*90px/100px=54px (instead of the incorrect value of 50px). Retour à l'exemple ci-dessus, afin de trouver la valeur nouvelle hauteur de la boîte je utiliser cette formule: = 100px/60px (100px-10px) / x et x = 60px * 90px/100px = 54px (au lieu de la valeur incorrecte de 50px). That's it! That's it!

Translate this post Translate this post


No related posts. Pas de postes.

    blog comments powered by Disqus Commentaires Blog powered by Disqus