Coding: Don't make mistakes when resizing objects! Codificación: non cometer erros cando redimensionar obxectos! Preserve the initial ratio correctly! Garda a proporción inicial correctamente!
Posted on 17. Posta en 17. Jun, 2009 by Dragos in Coding Xuño de 2009 por Dragos na Codificación
I was tempted many times to do quick adjustments to my code, without taking into consideration some basic mathematical principles. Fun tentado varias veces para facer axustes rápidos para o meu código, sen ter en conta algúns principios matemáticos básicos. 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. Para exemplos, unha caixa é ante todo 100px de alto e 60px de ancho, e entón entender que este cadro non se encaixa no lugar no que estaba destinado a ser feitas, o que eu fixen foi para subtrair 10 px de ancho da caixa, para que caiba ningunha área e, ao mesmo tempo, sustraído 10 px de alto tamén, pensando que así eu continúe facendo a relación entre o tamaño inicial do cadro. In fact this is not true! En realidade iso non é verdade!
Here's why: Eis o porqué:
The ratio of the initial box is 100px/60px=1.66 A relación da caixa principal é 100px/60px = 1,66
In the second case the ratio is: (100px-10px)/(60px-10px)=1.8 No segundo caso, a relación é: (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! Entón, se utilizou a aplicar a mesma técnica que eu fixen rapidamente redimensionar obxectos, esquece-lo, porque é malo! Instead use the old method from school to determine a variable from two fractions, preserving the ratios. Ao contrario diso, use o vello método da escola para determinar unha variable de dúas fraccións, conservando as proporcións. 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). Voltar o exemplo anterior, a fin de descubrir o novo valor da altura da caixa que eu usar esta fórmula: = 100px/60px (100px-10px) / x, entón x = 60px * 90px/100px = 54px (en vez de o valor incorrecto de 50px). That's it! That's it!
Related posts: Related posts:
- Coding: How to get code suggestions and function completion in Netbeans? Coding: Como obter suxestións de código de función e conclusión no NetBeans?
- Coding:How to fetch user profile data with SSI.php from a SMF forum database Coding: Como buscar datos de perfil de usuario con SSI.php dun banco de foro SMF












































