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 업데이 트를 통해 RSS | 이메일 Get updates via feedburner Get updates via twitter
Home / Coding / Coding: Don't make mis… / 코딩 / 코딩 : 불리하게 만들지 마 ...

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 두 번째 경우에는 비율 : (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. 대신 학교에서 변수를 결정하는 두 개의 분수에서 비율을 보존 오래된 방법을 사용합니다. 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 (대신 사용하십시오 상자의 새 높이 값을 찾을 수 50 픽셀의 잘못된 값). That's it! 바로 그거야!

Translate this post 번역이 게시물에


No related posts. 관련 게시물 없음.

    blog comments powered by Disqus 블로그 덧글 Disqus에 의해 제공