title: LESS: mixin for background position in sprites... implementing background size as well
body: <p>I made a simple mixin, that helps me generate background-position coordinates in a horizontal sprite</p>
  
  <pre><code>.bg_h_pos(@ind, @width){
      @left: -((@ind - 1) * @width);
      background-position: ~"@{left}px" 0px;
  }
  </code></pre>
  
  <p>works awesome</p>
  
  <pre><code>@icon_width: 50;
  .icon1{
      .bg_h_pos(1, @icon_width);
  }
  .icon2{
      .bg_h_pos(2, @icon_width);
  }
  
  ...
  </code></pre>
  
  <p>now I'd like to add a little complexity and implement background-size.</p>
  
  <pre><code>.bg_h_pos(@ind, @width, @background-size: auto){
      @left: -((@ind - 1) * @width);
      background-position: ~"@{left}px" 0px;
  }
  </code></pre>
  
  <p>I need something like this... where background size is defaulted to 1...
  if set to something else (like 0.6, 0,4 etc), then calculate new width and set background-position</p>
  
  <pre><code>.bg_h_pos(@ind, @width, @background-size: 1){
      if (@background-size != 1){
          @width = @width * @background-size;
          background-size: (ORIGINAL_WIDTH * @background-size)px auto;
      }
  
      @left: -((@ind - 1) * @width);
      background-position: ~"@{left}px" 0px;
  }
  </code></pre>
  
  <p>Any help? I need some good sources of complex mixins and calculations and conditional statements</p>