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 UPDATES VIA RSS | E-mail Get updates via feedburner Get updates via twitter
Home / Coding / Coding: Don't make mis… Home / Coding / Coding: niet mis te maken ...

Coding: Don't make mistakes when resizing objects! Coding: geen fouten maken bij het resizen objecten! Preserve the initial ratio correctly! Bewaar de aanvankelijke verhouding correct!

Posted on 17. Geplaatst op 17. Jun, 2009 by Dragos in Coding Juni, 2009 door Dragos in Coding

I was tempted many times to do quick adjustments to my code, without taking into consideration some basic mathematical principles. Ik was vele malen in de verleiding om snel aanpassingen doen om mijn code, zonder rekening te houden met een aantal fundamentele wiskundige principes. 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. Voor voorbeelden als een doos eerste is van alle 100px hoog en 60px breed, en dan merk ik dat dit vak niet de plaats waar het de bedoeling was fit te worden gebracht, wat ik deed was tot en met 10 px aftrekken van de breedte van de doos, want het enige gebied aan te passen, en op dezelfde tijd dat ik 10 px afgetrokken van de hoogte ook, denken dat doen, zodat ik de verhouding van de oorspronkelijke grootte van de doos bewaard. In fact this is not true! In feite is dit niet waar!

Here's why: Hier is waarom:

The ratio of the initial box is 100px/60px=1.66 De verhouding van de oorspronkelijke doos is 100px/60px = 1,66

In the second case the ratio is: (100px-10px)/(60px-10px)=1.8 In het tweede geval is de verhouding: (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! Dus als je gebruikt om dezelfde techniek toepassen zoals ik heb gedaan om snel objecten formaat, vergeet het, zoals het verkeerd! Instead use the old method from school to determine a variable from two fractions, preserving the ratios. In plaats daarvan gebruik van de oude methode van school om te bepalen een variabele uit twee fracties, met behoud van de ratio's. 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). Terug naar het voorbeeld hierboven, om uit te vinden de nieuwe hoogte waarde van de doos ik gebruik deze formule: 100px/60px = (100px-10px) / x, dus x = 60px = 54px * 90px/100px (in plaats van de onjuiste waarde van 50px). That's it! That's it!

Translate this post Translate this post


No related posts. Geen verwante posten.

    blog comments powered by Disqus blog comments powered by Disqus