Coding: Don't make mistakes when resizing objects! Coding: Machen Sie keine Fehler beim Anpassen der Objekte! Preserve the initial ratio correctly! Behalten Sie die erste Verhältniszahl, richtig?
Posted on 17. Gesendet am 17. Jun, 2009 by Dragos in Coding Juni 2009 von Dragos in Coding
I was tempted many times to do quick adjustments to my code, without taking into consideration some basic mathematical principles. Ich war versucht, oft eine schnelle Anpassungen an meinem Code zu tun, ohne Rücksicht auf einige grundlegende mathematische Grundsätze. 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. Beispiele, wenn ein Feld ist von allen 100px hoch und 60px breit erste und dann merke ich, daß dieses Feld nicht passt der Ort, wo sie unterliegen sollen, was ich tat, war, 10 px von der Breite der Box abziehen, nicht bis zu einem gewissen Bereich passen, und zur gleichen Zeit, die ich abgezogen 10 px von der Höhe auch, denke ich, dass dies das Verhältnis der ursprünglichen Größe der Box aufbewahrt. In fact this is not true! In der Tat ist dies nicht wahr ist!
Here's why: Hier die Gründe:
The ratio of the initial box is 100px/60px=1.66 Das Verhältnis der ersten Box ist 100px/60px = 1,66
In the second case the ratio is: (100px-10px)/(60px-10px)=1.8 Im zweiten Fall ist das Verhältnis: (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! Also, wenn Sie verwendet die gleiche Technik anwenden wie ich schnell Objekte skalieren, vergessen Sie es, wie es ist falsch! Instead use the old method from school to determine a variable from two fractions, preserving the ratios. Verwenden Sie stattdessen die alte Methode von der Schule in eine Variable bestimmen, von zwei Fraktionen, die Erhaltung der Verhältnisse. 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). Zum Beispiel oben, um herauszufinden, die neue Höhe Wert des Feldes ich diese Formel: 100px/60px = (100px-10px) / x, so dass x = 60px * 54px = 90px/100px (anstelle der Verwendung den falschen Wert von 50px). That's it! That's it!
No related posts. No related posts.












































