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 ACTUALIZACIONES VIA RSS | Email Get updates via feedburner Get updates via twitter
Home / Coding / Coding: Don't make mis… Inicio / Coding / Codificación: No cometer errores ...

Coding: Don't make mistakes when resizing objects! Codificación: No cometer errores al cambiar el tamaño de los objetos! Preserve the initial ratio correctly! Preservar la relación inicial correctamente!

Posted on 17. Publicado en 17. Jun, 2009 by Dragos in Coding Junio de 2009, por Dragos en la codificación de

I was tempted many times to do quick adjustments to my code, without taking into consideration some basic mathematical principles. Estuve tentado muchas veces para hacer ajustes rápidos a mi código, sin tener en cuenta algunos principios básicos de matemáticas. 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 ejemplos, si un cuadro es, ante todo 100px de alto y 60px de ancho, y luego me doy cuenta de que este cuadro no encaja en el lugar donde estaba destinada a ser colocada, lo que hizo fue restar 10 px de la anchura de la caja, para que se ajuste a alguna zona, y al mismo tiempo, me resta 10 px de la altura también, pensando que hacer, así que mantuvo la relación entre el tamaño inicial de la caja. In fact this is not true! En realidad esto no es cierto!

Here's why: He aquí por qué:

The ratio of the initial box is 100px/60px=1.66 La relación entre el cuadro inicial es 100px/60px = 1,66

In the second case the ratio is: (100px-10px)/(60px-10px)=1.8 En el segundo caso la proporción es: (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! Así que, si ha utilizado para aplicar la misma técnica que hice rápidamente cambiar el tamaño de los objetos, olvidarse de él, ya que está mal! Instead use the old method from school to determine a variable from two fractions, preserving the ratios. En su lugar utiliza el viejo método de la escuela para determinar una variable de dos fracciones, conservando las proporciones. 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). Volver al ejemplo anterior, con el fin de averiguar el valor de la nueva altura de la caja que haría uso de esta fórmula: 100px/60px = (100px-10px) / x, por lo que x = 60px * 90px/100px = 54px (en lugar de la el valor incorrecto de 50px). That's it! ¡Eso es!

Translate this post Traducir este mensaje


Related posts: Puestos relacionados con:

  1. Coding: How to get code suggestions and function completion in Netbeans? Codificación: Cómo llegar sugerencias sobre el código y completar la función en Netbeans?
  2. Coding:How to fetch user profile data with SSI.php from a SMF forum database Codificación: Cómo buscar datos de perfiles de usuario con SSI.php de una base de datos de foro SMF

    blog comments powered by Disqus blog alimentado por Disqus