Coding: Don't make mistakes when resizing objects! コーディング:ときにオブジェクトのサイズを変更ミスをしないでください! Preserve the initial ratio correctly! 正しく初期比を保持!
Posted on 17. 17日に掲載した。 Jun, 2009 by Dragos in Coding 6月、2009 ドラゴシュによる符号化で
I was tempted many times to do quick adjustments to my code, without taking into consideration some basic mathematical principles.何度も私のコードを簡単に調整を行うには、考慮するいくつかの基本的な数学の原理を受けずに誘惑された。 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.場合は、ボックスに、すべて100px高さ、幅60pxにして、初の例については、私は、このボックスを配置することが何かは、ボックスの幅を10ピクセルを減算していた場所を意図していたに適合しない場合は、通知のために、いくつかの領域に合わせて、私は高さも10ピクセルを引いたものと同時に、考え方には、従って私はボックスの[初期サイズの比率を維持を行う。 In fact this is not true!実際には真実ではないのです!
Here's why:理由はここです:
The ratio of the initial box is 100px/60px=1.66最初のボックスの比= 1.66 100px/60pxです
In the second case the ratio is: (100px-10px)/(60px-10px)=1.8 2番目のケースでは、比である:(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!だから、もし私がすぐにオブジェクトのサイズを変更するか、同じ手法を適用することを忘れない使用されるそれについては、それが悪いの! Instead use the old method from school to determine a variable from two fractions, preserving the ratios.代わりに、学校からの変数を決定する2つの分数から、比率を維持古いメソッドを使用します。 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).上記の例の先頭にで私はこの数式:100px/60px =(100px - 10px)/ xのため、Xの= 60px * 90px/100px = 54px(の代わりに使用したいのボックスの新しい高さの値を確認する50pxの不正な値です)。 That's it!それだよ!
No related posts.関連する記事。












































