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 अद्यतन Via आरएसएस | ईमेल 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 जून, 2009 Dragos द्वारा कोडिंग में

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 px घटाना हो गया है, के लिए यह कुछ क्षेत्र के लायक है, और उसी समय मैं ऊंचाई से भी 10 px subtracted में, यह सोचकर कि मैं इतना बॉक्स के प्रारंभिक आकार के अनुपात रखा कर रहे हैं. In fact this is not true! वास्तव में यह सच नहीं है!

Here's why: यहाँ क्यों है:

The ratio of the initial box is 100px/60px=1.66 प्रारंभिक बॉक्स के अनुपात 100px/60px = 1.66 है

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 (100px/60px, 10px) / x, तो x = * 90px/100px 54px = (के बजाय 60px का उपयोग करें चाहते हैं की नई ऊंचाई मूल्य 50px की गलत मूल्य). That's it! बस!

Translate this post अनुवाद इस पोस्ट


Related posts: संबंधित पोस्ट:

  1. Coding: How to get code suggestions and function completion in Netbeans? : कोडिंग कैसे कोड सुझाव और Netbeans में कार्य पूरा पाने के लिए?
  2. Coding:How to fetch user profile data with SSI.php from a SMF forum database : कोडिंग कैसे एक SMF मंच डेटाबेस से SSI.php के साथ उपयोगकर्ता प्रोफ़ाइल डेटा लाने के लिए

    blog comments powered by Disqus ब्लॉग टिप्पणियों Disqus द्वारा संचालित