In this example we generate a series of 6 color images, arranged so that they can be cut out and assembled into a 3-D color cube. The six faces of the cube represent the outside of the R-G-B color space. On each face one of the color components is fixed at either 0 or 255 and the other two components vary smoothly across the face from 0 to 255. The cube is configured as a right-handed coordinate system with x-y-z mapping R-G-B. Hence, the 8 corners of the cube represent the primaries red, green, and blue, plus the secondaries cyan, magenta and yellow, plus black and white.
The 6 color faces are generated by feeding grdimage three grids, one for each color component (R, G, and B). In some cases the X or Y axes of a face are reversed by specifying a negative width or height in order to change the variation of the color value in that direction from ascending to descending, or vice versa.
A number of rays emanating from the white and black corners indicate the Hue value (ranging from 0 to 360°). The dashed and dotted lines near the white corner reflect saturation levels, running from 0 to 1 (in black font). On these 3 faces the brightness is a constant value of 1. On the other 3 faces of the cube, around the black corner, the white decimal numbers indicate brightnesses between 0 and 1, with saturation fixed at 1.
Here is the shell script to generate the RGB cube:
#!/bin/csh # GMT EXAMPLE 11 # # Purpose: Create a 3-D RGB Cube # GMT progs: gmtset, grdimage, grdmath, pstext, psxy # Unix progs: rm # Use psxy to plot "cut-along-the-dotted" lines. gmtset TICK_LENGTH 0 COLOR_MODEL rgb CHAR_ENCODING Standard+ psxy cut-here.dat -Wthinnest,. -M -R-51/306/0/1071 -JX3.5i/10.5i -X2.5i -Y0.5i \ -P -U/-2.0i/-0.2i/"Example 11 in Cookbook" -K >! example_11.ps # First, create grids of ascending X and Y and constant 0. # These are to be used to represent R, G and B values of the darker 3 faces of the cube. grdmath -I1 -R0/255/0/255 X = x.grd grdmath -I1 -R Y = y.grd grdmath -I1 -R 0 = c.grd grdimage x.grd y.grd c.grd -JX2.5i/-2.5i -R -K -O -X0.5i >> example_11.ps psxy -M rays.dat -J -R -K -O -Bwesn >> example_11.ps echo 128 128 12 -45 1 MC "60\217" | pstext -Gwhite -J -R -K -O >> example_11.ps echo 102 26 12 -90 1 MC 0.4 | pstext -Gwhite -J -R -K -O >> example_11.ps echo 204 26 12 -90 1 MC 0.8 | pstext -Gwhite -J -R -K -O >> example_11.ps grdimage x.grd c.grd y.grd -JX2.5i/2.5i -R -K -O -Y2.5i >> example_11.ps psxy -M rays.dat -J -R -K -O -Bwesn >> example_11.ps echo 128 128 12 45 1 MC "300\217" | pstext -Gwhite -J -R -K -O >> example_11.ps echo 26 102 12 0 1 MC 0.4 | pstext -Gwhite -J -R -K -O >> example_11.ps echo 26 204 12 0 1 MC 0.8 | pstext -Gwhite -J -R -K -O >> example_11.ps grdimage c.grd x.grd y.grd -JX-2.5i/2.5i -R -K -O -X-2.5i >> example_11.ps psxy -M rays.dat -J -R -K -O -Bwesn >> example_11.ps echo 128 128 12 135 1 MC "180\217" | pstext -Gwhite -J -R -K -O >> example_11.ps echo 102 26 12 90 1 MC 0.4 | pstext -Gwhite -J -R -K -O >> example_11.ps echo 204 26 12 90 1 MC 0.8 | pstext -Gwhite -J -R -K -O >> example_11.ps # Second, create grids of descending X and Y and constant 255. # These are to be used to represent R, G and B values of the lighter 3 faces of the cube. grdmath -I1 -R 255 X SUB = x.grd grdmath -I1 -R 255 Y SUB = y.grd grdmath -I1 -R 255 = c.grd grdimage x.grd y.grd c.grd -JX-2.5i/-2.5i -R -K -O -X2.5i -Y2.5i >> example_11.ps psxy -M rays.dat -J -R -K -O -Bwesn >> example_11.ps echo 128 128 12 225 1 MC "240\217" | pstext -J -R -K -O >> example_11.ps echo 102 26 12 270 1 MC 0.4 | pstext -J -R -K -O >> example_11.ps echo 204 26 12 270 1 MC 0.8 | pstext -J -R -K -O >> example_11.ps grdimage c.grd y.grd x.grd -JX2.5i/-2.5i -R -K -O -X2.5i >> example_11.ps psxy -M rays.dat -J -R -K -O -Bwesn >> example_11.ps echo 128 128 12 -45 1 MC "0\217" | pstext -J -R -K -O >> example_11.ps echo 26 102 12 0 1 MC 0.4 | pstext -J -R -K -O >> example_11.ps echo 26 204 12 0 1 MC 0.8 | pstext -J -R -K -O >> example_11.ps grdimage x.grd c.grd y.grd -JX-2.5i/2.5i -R -K -O -X-2.5i -Y2.5i >> example_11.ps psxy -M rays.dat -J -R -K -O -Bwesn >> example_11.ps echo 128 128 12 135 1 MC "120\217" | pstext -J -R -K -O >> example_11.ps echo 26 102 12 180 1 MC 0.4 | pstext -J -R -K -O >> example_11.ps echo 26 204 12 180 1 MC 0.8 | pstext -J -R -K -O >> example_11.ps echo 200 200 16 225 1 MC GMT 4 | pstext -J -R -O >> example_11.ps \rm -f *.grd .gmt*
The cube can be viewed in Figure 7.11.