RGB Colorspace

RGB (Red, Green, Blue)

RGB Colorspace is one of the most common colorspaces used today. It is used for many uncompressed image formats and computer displays. In RGB, there are 3 channels, each one indicating how much of a given color the final color has. These channels indicate Redness (the Red or R channel), Blueness (the Blue or B channel), and Greeness (the Green or G Channel). Combining these components allows us to make almost any color humans can see (though some combinations are not very intuitive, like Red + Green = Yellow). Sometimes the components are given in reverse order: BGR.

Blending RGB colors

Blending colors in RGB space is straightforward. Sum like components, and then divide by the number of inputs. Simple linear algebra!
Adding 2 colors evenly:
R3 = (R1 + R2)/2
G3 = (G1 + G2)/2
B3 = (B1 + B2)/2

A more flexible for would scale the inputs, as follows:
R3 = (R1*Alpha + R2*(1-Alpha))/2
G3 = (G1*Alpha + G2*(1-Alpha))/2
B3 = (B1*Alpha + B2*(1-Alpha))/2
Where Alpha is a number between 0 and 1. This variation is commonly called RGBA colorspace, and can be used to define transparency as well as color.

Adding RGB colors

Adding colors in RGB space is very simple. You simply add like components, and clamp the values so you don't overflow or underflow.
R3 = clamp(R1 + R2)
G3 = clamp(G1 + G2)
B3 = clamp(B1 + B2)
Styles: Default · Green · Sianse