Coding: Don't make mistakes when resizing objects! Coding: Ne delaj napak pri resizing predmeti! Preserve the initial ratio correctly! Ohranimo začetno razmerje pravilno!
Posted on 17. Objavljeno dne 17. Jun, 2009 by Dragos in Coding Junij 2009, ki ga Dragos v Coding
I was tempted many times to do quick adjustments to my code, without taking into consideration some basic mathematical principles. Bil sem mika, večkrat storiti hitro prilagoditev na moje kode, pri čemer se ne upošteva nekaj osnovnih matematičnih načelih. 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. Za primer, če polje je najprej 100px visok in širok 60px, nato pa sem opazil, da to polje ne ustreza kraju, kjer se je nameravala dati, kar sem naredila, je bilo za odštevanje 10 px od širine polja, za to, da nekatera območja fit, in ob istem času sem odšteti od 10 px višine tudi, misleč, da tem sem redno razmerje začetne velikosti polja. In fact this is not true! Pravzaprav to ni res!
Here's why: Evo zakaj:
The ratio of the initial box is 100px/60px=1.66 Razmerje začetnega polja, je 100px/60px = 1,66
In the second case the ratio is: (100px-10px)/(60px-10px)=1.8 V drugem primeru je razmerje: (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! Torej, če ste uporabili uporabiti isto tehniko, kot sem storil, da hitro spremeniti velikost predmetov, pozabi, saj je narobe! Instead use the old method from school to determine a variable from two fractions, preserving the ratios. Namesto tega uporabite metode iz stare šole za določitev spremenljivke iz dveh delov, ohranjanja razmerja. 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). Nazaj na zgornji primer, da bi ugotovili, novo vrednost višine polja sem uporabo te formule: 100px/60px = (100px-10px) / x, to x = 60px * 90px/100px = 54px (namesto nepravilna vrednost 50px). That's it! To je to!
No related posts. No related posts.












































