title: How to blend two texture colors in Libgdx
body: <p>I'm trying to blend two circles, one black and the other white. The parts where they intersect must be in grey.
  I tried to use blend functions but I don't get the expected results.</p>
  
  <p>The objective is to mix ONLY this two elements, other elements (like the background) can't mix there, and I don't know how to do this maintaining the 100% of the alpha channel.</p>
  
  <p>This is my current render code, circle1 and circle2 are TextureRegion.</p>
  
  <pre><code>public void draw(Batch batch, float parentAlpha) {
      super.draw(batch, parentAlpha);
      batch.enableBlending();
      batch.setBlendFunction(GL20.GL_ONE, GL20.GL_ONE);
  
      batch.draw(circle1, c1.getX(), getY(), getWidth(), getHeight());
      batch.draw(circle2, c2.getX(), getY(), getWidth(), getHeight());
  
  }
  </code></pre>
  
  <p>This is an example of the color mix.
  <img src="https://i.stack.imgur.com/oz7h8.jpg" alt="blend example"></p>
  
  <p>EDIT: Problem solved.
  I did a test using Spritebatch, I drew a third circle with reduced opacity, this is the code used to test and the result:</p>
  
  <pre><code>        Gdx.gl20.glEnable(GL20.GL_BLEND);
          Gdx.gl20.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
          shapeRenderer.setProjectionMatrix(camera.combined);
          shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
          shapeRenderer.setColor(1, 1, 1, 1f);
          shapeRenderer.circle(15, 5, 5);
          shapeRenderer.setColor(0, 0, 0, 1f);
          shapeRenderer.circle(19, 5,5);
          shapeRenderer.setColor(1, 1, 1, 0.5f);
          shapeRenderer.circle(15, 5, 5);
          shapeRenderer.end();
          Gdx.gl20.glDisable(GL20.GL_BLEND);
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/VMwy7.png" alt="solved problem"></p>