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 Ažuriranja putem RSS | E-mail Get updates via feedburner Get updates via twitter
Home / Coding / Coding: Don't make mis… Home / Kodiranje / Coding: Ne da mis ...

Coding: Don't make mistakes when resizing objects! Coding: Ne griješimo kada se promjena veličine objekata! Preserve the initial ratio correctly! Sačuvaj početni omjer ispravno!

Posted on 17. Poslano na 17. Jun, 2009 by Dragos in Coding Jun, 2009 by Dragos u kodiranju

I was tempted many times to do quick adjustments to my code, without taking into consideration some basic mathematical principles. Bio sam u iskušenju i mnogo puta učiniti brzo namještanje na moj broj, bez uzimanja u obzir nekih osnovnih matematičkih principa. 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 primjere ako kutija je prije svega 100px visok i širok 60px, a onda sam obavijest da se ovaj okvir, ne stane na mjesto gdje je bio namijenjen da bude stavljen, što sam učinio bilo je oduzimanje 10 px od širine okvira, za to da odgovara nekom području, a ujedno sam oduzeti 10 px od visine isto tako, misleći da se radi pa sam nastavio omjer početne veličine okvira. In fact this is not true! U stvari to nije istina!

Here's why: Evo zašto:

The ratio of the initial box is 100px/60px=1.66 Omjer početni okvir je 100px/60px = 1,66

In the second case the ratio is: (100px-10px)/(60px-10px)=1.8 U drugom slučaju omjer je: (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! Dakle, ako ste koristili primijeniti istu tehniku kao što sam to učinio brzo mijenjati veličinu objekata, zaboraviti o tome, jer to nije u redu! Instead use the old method from school to determine a variable from two fractions, preserving the ratios. Umjesto toga koriste stare metode iz škole utvrditi varijable iz dvije frakcije, očuvanju omjeri. 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). Natrag na primjeru gore, kako bi saznali nove visine vrijednost okvira bih iskoristiti ovu formulu: 100px/60px = (100px-10px) / x, pa x = 60px * 90px/100px = 54px (umjesto kriv vrijednost 50px). That's it! That's it!

Translate this post Translate this post


No related posts. Nema povezanih postova.

    blog comments powered by Disqus Blog komentari powered by Disqus