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 Aggiornamenti via RSS | Email Get updates via feedburner Get updates via twitter
Home / Coding / Coding: Don't make mis… Home / Coding / Coding: Non fare mis ...

Coding: Don't make mistakes when resizing objects! Coding: non commettere errori durante il ridimensionamento degli oggetti! Preserve the initial ratio correctly! Preservare il rapporto iniziale in maniera corretta!

Posted on 17. Posted on 17. Jun, 2009 by Dragos in Coding Giugno, 2009 da Dragos in Coding

I was tempted many times to do quick adjustments to my code, without taking into consideration some basic mathematical principles. Sono stato tentato molte volte di fare regolazioni rapide per il mio codice, senza prendere in considerazione alcuni principi di base matematica. 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. Per esempio, se una casella è prima di tutto 100px alto e 60px di larghezza, e poi mi accorgo che questa finestra non si adatta al luogo in cui è stato destinato ad essere immesso, quello che ho fatto era quello di sottrarre 10 px dalla larghezza della finestra, per la sua forma una certa zona, e al tempo stesso ho sottratto 10 px dall'alto anche, pensando che così facendo ho mantenuto il rapporto tra le dimensioni iniziali della finestra. In fact this is not true! In realtà questo non è vero!

Here's why: Ecco perché:

The ratio of the initial box is 100px/60px=1.66 Il rapporto tra la finestra iniziale è 100px/60px = 1,66

In the second case the ratio is: (100px-10px)/(60px-10px)=1.8 Nel secondo caso il rapporto è: (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! Quindi, se è stato utilizzato per applicare la stessa tecnica, come ho fatto in fretta a ridimensionare gli oggetti, dimenticare, come è sbagliato! Instead use the old method from school to determine a variable from two fractions, preserving the ratios. Invece utilizzare il vecchio metodo dalla scuola per determinare una variabile da due frazioni, conservando i rapporti. 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). Torna l'esempio di cui sopra, al fine di scoprire il nuovo valore di altezza della finestra che avevo utilizzare questa formula: 100px/60px = (100px-10px) / x, quindi x = 60px * 90px/100px = 54px (invece di il valore errato di 50px). That's it! That's it!

Translate this post Traduci questo post


No related posts. No related posts.

    blog comments powered by Disqus commenti del blog powered by Disqus