title: How to sum RGBA colors
body: <p>I'm searching a way to sum two <a href="https://en.wikipedia.org/wiki/RGBA_color_space" rel="nofollow">RGBA</a> colors. Here's what I do :</p>
  
  <pre><code>RGBA c1, c2
  RGB c3 = rgba_to_rgb(c1)
  RGB c4 = rgba_to_rgb(c2)
  
  RGB r = c3 + c4
  
  RGBA r1 = rgb_to_rgba(r) // I don't know how to implement this function
  </code></pre>
  
  <p>How can I sum c1 and c2 without converting them to RGB. In my program I have to sum four RGBA colors. I have this instruction :</p>
  
  <pre><code>Color r = 1.f/4 * (c1+c2+c3+c4)
  </code></pre>
  
  <p>I have to implement the + operator for RGBA colors.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>For RGB color when sum two colors I do this :</p>
  
  <pre><code>RGB r;
  r.red = c1.red + c2.red
  r.green = c1.green + c2.green
  r.blue = c1.blue + c2.blue
  </code></pre>
  
  <p>I don't know what to do for RGBA color. My first idea is to convert the two colors to RGB then do the sum (because I know how to do it for RGB colors) then convert back to RGBA. The second solution is to find out how to directly the addition with RGBA colors.</p>