#!/bin/csh # # Example 11: Create a 3-D RGB Cube # # First create a Plane from (0,0,0) to (255,255,255). # Only needs to be done once, and is used on each of the 6 faces of the cube. # echo "Creating z-grid..." grdmath -I1 -R0/255/0/255 -V Y 256 MUL X ADD = rgb_cube.grd # # For each of the 6 faces, create a color palette with one color (r,g,b) fixed # at either the min. of 0 or max. of 255, and the other two components # varying smoothly across the face from 0 to 255. # # This uses awk script "rgb_cube.awk", with arguments specifying which color # (r,g,b) is held constant at 0 or 255, which color varies in the x-direction # of the face, and which color varies in the y-direction. If the color is to # increase in x (y), a lower case x (y) is indicated; if the color is to # decrease in the x (y) direction, an upper case X (Y) is used. # # Use grdimage to paint the faces and psxy to add "cut-along-the-dotted" lines. # gmtset TICK_LENGTH 0 pstext -R0/8/0/11 -Jx1 < /dev/null -P -U"Example 11 in Cookbook" -K >! example_11.ps echo -n "Top..." awk -f rgb_cube.awk r=x g=y b=255 < /dev/null >! rgb_cube.cpt grdimage rgb_cube.grd -Crgb_cube.cpt -JX2.56/2.56 -R0/255/0/255 -K -O -X1.97 -Y4.5 -B256wesn >> example_11.ps echo -n " Right..." awk -f rgb_cube.awk r=255 g=y b=X < /dev/null >! rgb_cube.cpt grdimage rgb_cube.grd -Crgb_cube.cpt -JX -K -O -X2.56 -B256wesn >> example_11.ps echo -n " Back"... awk -f rgb_cube.awk r=x g=255 b=Y < /dev/null >! rgb_cube.cpt grdimage rgb_cube.grd -Crgb_cube.cpt -JX -K -O -X-2.56 -Y2.56 -B256wesn >> example_11.ps psxy -W1to -JX -R -K -O -X2.56 << END >> example_11.ps 0 0 20 20 20 235 0 255 END psxy -W1to -JX -R -K -O -X-2.56 -Y2.56 << END >> example_11.ps 0 0 20 20 235 20 255 0 END psxy -W1to -JX -R -K -O -X-2.56 -Y-2.56 << END >> example_11.ps 255 0 235 20 235 235 255 255 END echo -n " Left"... awk -f rgb_cube.awk r=0 g=y b=x < /dev/null >! rgb_cube.cpt grdimage rgb_cube.grd -Crgb_cube.cpt -JX -K -O -Y-2.56 -B256wesn >> example_11.ps echo -n " Front"... awk -f rgb_cube.awk r=x g=0 b=y < /dev/null >! rgb_cube.cpt grdimage rgb_cube.grd -Crgb_cube.cpt -JX -K -O -X2.56 -Y-2.56 -B256wesn >> example_11.ps pstext -JX -R -G255 -K -O << END >> example_11.ps 10 10 14 0 -Times-BoldItalic 1 GMT 3 END psxy -W1to -JX -R -K -O -X2.56 << END >> example_11.ps 0 0 20 20 20 235 0 255 END psxy -W1to -JX -R -K -O -X-5.12 << END >> example_11.ps 255 0 235 20 235 235 255 255 END echo -n " Bottom"... awk -f rgb_cube.awk r=x g=Y b=0 < /dev/null >! rgb_cube.cpt grdimage rgb_cube.grd -Crgb_cube.cpt -JX -K -O -X2.56 -Y-2.56 -B256wesn >> example_11.ps psxy -W1to -JX -R -K -O -X2.56 << END >> example_11.ps 0 0 20 20 20 235 0 255 END psxy -W1to -JX -R -O -X-5.12 << END >> example_11.ps 255 0 235 20 235 235 255 255 END echo " Done\!" \rm -f rgb_cube.cpt rgb_cube.grd .gmtcommands