MaxwellTriangleSmall.gif (1250 bytes) Maxwell Triangle  Lab Report
Display of Maxwell Triangle
ScreenMaxwellEquilateral.jpg (46240 bytes)

The black dot near the middle shows the location of the chromaticity point xyz = (0.25, 0.50, 0.25).
(Ignore JPEG compression artifacts.)

The purpose of this experiment is to demonstrate the mixture of colored lights and to introduce the concept of chromaticity coordinates.

The Maxwell triangle shows a set of three additive primary colors and the complete gamut of colors obtainable by mixing two or three of them together.  This triangle is named after the Scottish physicist James Clerk Maxwell (1831-1879), who employed it in his basic work on color [Agoston87, p. 48].

Along the sides of a Maxwell triangle mixing of two of the three color components occurs with every possible proportion.  As one travels from the side towards the center, the third primary becomes increasingly important.  Near the center at the "equal energy" point, E, a true white is seen.

The Maxwell triangle shows the quality aspect of psychophysical color, which is called chromaticity.  This quality aspect shows hue and saturation, but does not indicate the quantity aspect of psychophysical color, which is the effective amount of light.

By CIE convention, the absolute values of Red, Green and Blue light are represented by the quantities X, Y and Z, while the fractional values (the chromaticity coordinates) are represented by the quantities x, y and z.  (The convention of using x for Red, y for Green and z for Blue will be helpful in the study of the CIE Chromaticity diagram.)  Since by definition, x + y + z = 1, only two of the fractional amounts are necessary to locate a point and specify its chromaticity, which usually are the x and y values (see the right triangle display in the program below). 

See the References [Agoston87] and [Chamberlin80] for additional information.

Materials and Equipment

Software Requirements
Windows 95/98/NT
Delphi 3/4  (to recompile)

Hardware Requirements
800-by-600 display in High Color or True Color Mode
(palettes may not be correct in 256 color mode)


  1. Double click on the MaxwellTriangle.EXE icon to start the program.
  2. Study the (x, y, z) chromaticity coordinates by selecting or de-selecting the various decile lines, and by moving the cursor over the diagram to see the coordinates at the bottom of the display.
  3. If desired, select the Print or Save To File buttons to print the image or write it to a BMP file.
  4. If desired, switch between the Equilateral and Right Triangle display using the combobox.

The triangles to display, print or to write to a file are created in routine CreateMaxwellTriangle in a square bitmap as a function of the size of the square bitmap.  The coordinates of the Blue, Green and Red corners were calculated as follows:

Point Equilateral Triangle Right Triangle
Blue iB 2% size 10% size
jB size - offset 90% size
Green iG 50% size 10% size
jG offset 10% size
Red iR 98% size 90% size
jR size - offset 90% size


    offset = [ size - (96% size)*SQRT(3)/2) ] / 2,

"i" is used as a prefix to designate the "x" direction,
"j" is used as a prefix to designate the "y" direction,
and the y-axis is assumed to increase from top to bottom.

The "Decile lines" were formed, when requested for either the equilateral or right triangle, by breaking two specified sides into 10 parts.

To fill in the Maxwell triangle, the (x, y ,z) chromaticity coordinates were calculated for each pixel location.  The scanlines were considered from top (jG) to bottom (jB) in the bitmap.  For a given scanline j,

     maximum xChromaticity = (j  - jG) / (jB - jG)

     yChromaticity = 1 - maximum xChromaticity

For each scanline j, the i pixels range from iLeft to iRight as defined by

    iLeft = iG + xMax*(iB - iG)

    iRight = iG + xMax*(iR - iG)

Note that with the right triangle, since iB - iG, iLeft = iG for all scanlines.

ScreenMaxwellRightTriangle.jpg (37002 bytes)
Display of right triangle with cursor at the "equal energy point," E = (1/3, 1/3, 1/3).
Notice that all points can be specified with only xChromaticity and yChromaticity.

For pixel i in scanline j:

     xChromaticity = xMax * (i - iLeft) / (iRight - iLeft)


     zChromaticity = 1 - xChromaticity - yChromaticity

Now with the  (x, y ,z) chromaticity coordinates defined, how should the R, G, B values be defined over the range 0.0 to 1.0?

To make the point with equal energy the brightest white, the following procedure is used:

     maxFraction = max(xChromaticity, yChromaticity, zChromaticity)

     Red = xChromaticity / maxFraction

     Green = yChromaticity / maxFraction

     Blue = zChromaticity / maxFraction

In this way the point with chromaticity coordinates (1/3, 1/3, 1/3) is assigned to RGB (1.0, 1.0, 1.0).

Multiply by 255 to convert RGB values from the range 0.0 to 1.0 to 0 to 255.  Thus, RGB (1.0, 1.0, 1.0) is the same as RGB (255, 255, 255) and is the equal energy point, E.

During the OnMouseMove events, which are created by moving the mouse cursor across the screen, the (x,y,z) chromaticity coordinates are displayed at the bottom of the screen.  These xyz values are computed in the ImageMouseMove method by solution of the following system of equations using Cramer's rule for the MouseMove point (i,j).

xyzChromaticity.gif (1946 bytes)

Once xChromaticity and yChromaticity are known, zChromaticity is computed using the equation

    zChromaticity = 1 - xChromaticity - yChromaticity

When any of the xChromaticity, yChromaticity, zChromaticity values are negative, the point at the mouse cursor is outside the Maxwell triangle.  When one of these values is negative, the message at the bottom of the screen is "Outside of Gamut."

Note that the same parametric definition of the Maxwell triangle works well with both the equilateral and right triangle displays.

A Maxwell triangle shows the various Red-Green-Blue combinations of three additive primary colors. 

The gamut of possible colors for a display device is defined by a Maxwell triangle in a CIE Chromaticity Chart.  The corners of such a Maxwell triangle in a CIE Chromaticity Chart are determined by the chromaticity coordinates of the Red-Green-Blue phosphors used in the monitor.


[Agoston87] George A. Agoston, Color Theory and Its Application in Art and Design, Springer-Verlag, Berlin, 1987, pp. 48-53.
[Chamberlin80] G.J. Chamberlin and D.G. Chamberlin, Colour:  Its Measurement, Computation and Application, London:  Heyden, 1980,  pp. 50-52.
efg's Color Science Page

Maxwell Triangle, xyz Chromaticity Coordinates, RGB Coordinates, Bitmap.Scanline, Canvas.MoveTo, Canvas.LineTo, OnMouseMove, Cramer's Rule, MulDiv, point in triangle algorithm

Delphi 3/4 Source and EXE (148 KB):  MaxwellTriangle.ZIP

Point in Triangle Test

Dave Eberly's UseNet Post:  Let the points be (x0,y0,z0), (x1,y1,z1), (x2,y2,z2).  Given (x,y), solve for s and t in (x,y) = (x0,y0)+s*(x1-x0,y1-y0)+t*(x2-x0,y2-y0).  The point is inside the triangle if s >= 0, t >= 0, and s+t <= 1.  Then choose z = (1-s-t)*z0+s*z1+t*z2.

Updated 26 Feb 2005

since 07 Mar 1999