title: libgdx ScissorStack not working as expected
body: <p>I'm trying to create a "progress bar" of sorts but the clipping doesn't seem to work the way I expect it to. Is this something I am doing wrong or something I've misinterpreted?</p>
  
  <p>The <code>draw()</code> routine that should clip:</p>
  
  <pre><code>    @Override
      public void draw(SpriteBatch batch, float parentAlpha) {
          Rectangle scissors = new Rectangle();
          Rectangle clipBounds = new Rectangle(getX(), getY(), getWidth() * 0.75f, getHeight());
  
          ScissorStack.calculateScissors(
                  getStage().getCamera(),
                  getStage().getGutterWidth(),
                  getStage().getGutterHeight(),
                  getStage().getCamera().viewportWidth,
                  getStage().getCamera().viewportHeight,
                  batch.getTransformMatrix(),
                  clipBounds, scissors);
  
          if (ScissorStack.pushScissors(scissors)) {
              super.draw(batch, parentAlpha);
              ScissorStack.popScissors();
          }
      }
  }
  </code></pre>
  
  <p>Complete sample code for <a href="http://pastebin.com/0buBn5eL" rel="nofollow noreferrer">ClipTest group</a> class, <a href="http://pastebin.com/XS5VV3rU" rel="nofollow noreferrer">TestScreen</a> and screenshot.</p>
  
  <p><img src="https://i.stack.imgur.com/sfDyA.png" alt="enter image description here"></p>
  
  <ul>
  <li><code>ClipTest</code> is a subclass of group used to demonstrate the "bug".</li>
  <li><code>ClipImage</code> is a subclass of Image, which performs the clipping on <code>draw()</code>.</li>
  <li><code>ClipTest</code> has 2 images, background and foreground.</li>
  </ul>
  
  <p>The background is a black image and it should always be the full size of the progress bar.</p>
  
  <p>The foreground is a white image and it's width is clipped depending on the percentage of the bar.</p>
  
  <p>The strange result I've found is that although the foreground is using the clipping class, the background image is the one actually clipped.</p>
  
  <p>The expected result was created using photoshop (as I couldn't produce it via code).</p>
  
  <p>Any idea what's wrong?</p>