Coding: Don't make mistakes when resizing objects! Coding: Ne hibázni átméretezésekor tárgyakat! Preserve the initial ratio correctly! Megőrizze a kezdeti arány helyesen!
Posted on 17. Posted on 17. Jun, 2009 by Dragos in Coding Június, 2009 Dragos a Coding
I was tempted many times to do quick adjustments to my code, without taking into consideration some basic mathematical principles. Én kísértés, többször nem gyors kiigazítását a kódomat, anélkül, hogy figyelembe véve néhány alapvető matematikai elveket. 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. Mert ha a példát egy doboz először 100px magas, 60px széles, majd észreveszem, hogy ebbe a rovatba nem illik a hely, ahol meg kívánják kötni, amit tettem az volt, hogy vonjuk ki a 10 px széles a doboz, mert hogy illeszkedjen egy területet, és ezzel egyidejűleg az I. vonni 10 px a magassága is, gondolván, hogy ezzel én csak az arány az eredeti mérete mezőben. In fact this is not true! Valójában ez nem igaz!
Here's why: Itt Hogy miért?
The ratio of the initial box is 100px/60px=1.66 Viszonyítva az eredeti doboz 100px/60px = 1,66
In the second case the ratio is: (100px-10px)/(60px-10px)=1.8 A második esetben az arány: (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! Szóval, ha használni ugyanazt a technikát alkalmazza, mint én, hogy gyorsan átméretezni objektumokat, felejtsd el, mivel ez a baj! Instead use the old method from school to determine a variable from two fractions, preserving the ratios. Helyett a régi módszer az iskolai meghatározni egy változó két frakció, megőrizve az arányokat. 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). Vissza a fenti példához, annak érdekében, hogy megtudja az új magasság értékét a doboz Szeretném ezt a képletet: 100px/60px = (100px-10px) / x, ezért x = 60px * 54px = 90px/100px (ahelyett, hogy A helytelen érték 50px). That's it! That's it!
No related posts. Nincs kapcsolódó álláshely.












































