title: How do you call a less.js function
body: <p>I'm not even really sure how to ask this. The LESS CSS Framework contains several functions to manipulate color, I'd like to know how to call these functions myself to modify a color. The problem is that these functions are located inside another function and defined as such:</p>
  
  <pre><code>(function (tree) {
  tree.functions = {
      darken: function(color, amount){
          ...stuff...
      }
  }
  }
  </code></pre>
  
  <p>I know enough to assume that <strong>darken</strong> is a method of <strong>tree.functions</strong>, but for the life of me don't know how to call it because it is inside of the anonymous function <strong>(function (tree)</strong>. </p>
  
  <p><strong>[edit]</strong>
  After getting a solution from @pradeek I created this function incase anyone needs it. Can easily be adapted to all the other functions LESS has:</p>
  
  <pre><code>var lessColor = {
  /*
  |--------------------------------------------------------------------------
  | Darken
  |--------------------------------------------------------------------------
  */
  darken: function(col, val){
      col = col.replace(/#/g, '');    //Remove the hash
  
      var color = new less.tree.Color(col);   //Create a new color object
      var amount = new less.tree.Value(val);      //Create a new amount object
      var newRGB = less.tree.functions.darken(color, amount); //Get the new color
      var hex = (newRGB.rgb[0] + 256 * newRGB.rgb[1] + 65536 * newRGB.rgb[2]).toString(16);
      hex = hex.split('.', 1);    //Remove everything after the decimal if it exists
  
      //Add padding to the hex to make it 6 characters
      while(hex.length &lt; 6){
          hex = hex+'0';
      }
      hex = '#'+hex;  //Add the hash
  
      return hex; //return the color
  }
  }
  </code></pre>
  
  <p>And you can call it like so:</p>
  
  <pre><code>$(this).css('background', lessColor.darken($(this).css('background'), .25);
  </code></pre>