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 UPDATES VIA RSS | Email Get updates via feedburner Get updates via twitter
Home / Coding / Coding: Don't make mis… Home / Coding / Coding: Jangan membuat mis ...

Coding: Don't make mistakes when resizing objects! Coding: Jangan membuat kesalahan ketika mengubah ukuran objek! Preserve the initial ratio correctly! Mempertahankan rasio awal dengan benar!

Posted on 17. Dikirim di 17. Jun, 2009 by Dragos in Coding Jun, 2009 oleh Dragos di Coding

I was tempted many times to do quick adjustments to my code, without taking into consideration some basic mathematical principles. Aku tergoda beberapa kali untuk melakukan penyesuaian dengan cepat kode saya, tanpa mempertimbangkan prinsip-prinsip matematika dasar. 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. Sebagai contoh jika kotak pertama-tama dan 60px tinggi 100px lebar, dan kemudian aku melihat bahwa kotak ini tidak cocok dengan tempat itu dimaksudkan untuk ditempatkan, apa yang saya lakukan adalah mengurangi 10 px dari lebar kotak, untuk itu agar sesuai dengan beberapa daerah, dan pada saat yang sama saya dikurangi 10 px dari ketinggian juga, berpikir bahwa melakukan hal itu aku tetap rasio ukuran awal dari kotak. In fact this is not true! Sebenarnya hal ini tidak benar!

Here's why: Here's why:

The ratio of the initial box is 100px/60px=1.66 Rasio dari kotak awal 100px/60px = 1,66

In the second case the ratio is: (100px-10px)/(60px-10px)=1.8 Dalam kasus kedua rasio adalah: (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! Jadi, jika Anda digunakan untuk menerapkan teknik yang sama seperti yang saya lakukan dengan cepat mengubah ukuran objek, lupakan saja, karena itu salah! Instead use the old method from school to determine a variable from two fractions, preserving the ratios. Alih-alih menggunakan metode lama dari sekolah untuk menentukan variabel dari dua fraksi, menjaga rasio. 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). Kembali ke contoh di atas, dalam rangka untuk mengetahui nilai tinggi baru dari kotak saya akan menggunakan rumus ini: 100px/60px = (100px-10px) / x, jadi x = 60px * 90px/100px = 54px (bukan nilai yang salah 50px). That's it! That's it!

Translate this post Terjemahkan posting ini


No related posts. No related posts.

    blog comments powered by Disqus blog comments powered by DISQUS