/*License Agreement for Corrective Code or Additional Functionality SAS INSTITUTE INC. IS PROVIDING YOU WITH THE COMPUTER SOFTWARE CODE INCLUDED WITH THIS AGREEMENT ("CODE") ON AN "AS IS" BASIS, AND AUTHORIZES YOU TO USE THE CODE SUBJECT TO THE TERMS HEREOF. BY USING THE CODE, YOU AGREE TO THESE TERMS. YOUR USE OF THE CODE IS AT YOUR OWN RISK. SAS INSTITUTE INC. MAKES NO REPRESENTATION OR WARRANTY, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT AND TITLE, WITH RESPECT TO THE CODE. The Code is intended to be used solely as part of a product ("Software") you currently have licensed from SAS or one of its subsidiaries or authorized agents ("SAS"). The Code is designed to either correct an error in the Software or to add functionality to the Software, but has not necessarily been tested. Accordingly, SAS makes no representation or warranty that the Code will operate error-free. SAS is under no obligation to maintain or support the Code. Neither SAS nor its licensors shall be liable to you or any third party for any general, special, direct, indirect, consequential, incidental or other damages whatsoever arising out of or related to your use or inability to use the Code, even if SAS has been advised of the possibility of such damages. Except as otherwise provided above, the Code is governed by the same agreement that governs the Software. If you do not have an existing agreement with SAS governing the Software, you may not use the Code. (SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. Other brand and product names are registered trademarks or trademarks of their respective companies.)*/ Names Default To Here( 1 ); Clear Log(); dt = New Table( "RGB Space", Add Rows( 0 ), Suppress Formula Eval( 1 ), New Script( "Ternary Plot", Ternary Plot( Y( :Red, :Green, :Blue ), SendToReport( Dispatch( {}, "Ternary Plot", FrameBox, {Marker Size( 0 )} ) ) ) ), New Script( "Scatter Plot 3D", Scatterplot 3D( Y( :Red, :Green, :Blue, :Brightness ), Frame3D( Set Grab Handles( 0 ), Set Rotation( -54, 0, 38 ) ) ) ), New Column( "Color", Expression, Formula( Color To RGB( Color Of( Row State() ) ) ) );, New Column( "Red", Numeric, "Continuous", Format( "Best", 12 ), Formula( Color To RGB( Color Of( Row State() ) )[1] ) ), New Column( "Green", Numeric, "Continuous", Format( "Best", 12 ), Formula( Color To RGB( Color Of( Row State() ) )[2] ) ), New Column( "Blue", Numeric, "Continuous", Format( "Best", 12 ), Formula( Color To RGB( Color Of( Row State() ) )[3] ) ), New Column( "Brightness", Numeric, "Continuous", Format( "Best", 12 ), Formula( Mean( :Red, :Green, :Blue ) ) ) ); dt << Clear Select; dt << Clear Column Selection; // Initialize the row counter i = 1; // Resolution (8-bit) rez = 32; // Intialize the color string colorlist = {}; Caption( "Processing data. Please be patient." ); Wait( 0 ); dt << BeginDataUpdate; //Blue Loop For( b = 0, b <= (rez - 1), b++, //Green Loop For( g = 0, g <= (rez - 1), g++, //Red Loop For( r = 0, r <= (rez - 1), r++, //Calculate the percentage rgb values red = r / (rez - 1); green = g / (rez - 1); blue = b / (rez - 1); //Create the color list for the column property rgbColor = RGB Color( red, green, blue ); Insert Into( colorlist, rgbColor ); //Update the counters and displays. i++; If( Mod( i, 1000 ) == 0, Caption( "Generating Color Matrix\!N Processed " || Char( i ) || " values (" || Char( Round( i / (rez ^ 3), 3 ) * 100 ) || "%)." ); Wait( 0 ); ); ) ) ); dt << EndDataUpdate; Caption( "Color Matrix contains " || Char( N Items( colorlist ) ) || " colors." ); Wait( 0 ); dt << Add Rows( rez ^ 3 ); For( i = 1, i <= N Items( colorlist ), i++, dt << Select Rows( i ); dt << Colors( colorlist[i] ); :Color << Color Cells( RGB Color( colorlist[i] ), i ); dt << Clear Select; If( Mod( i, 1000 ) == 0, Caption( "Populating Data Table with Colors\!N Processed " || Char( i ) || " values (" || Char( Round( i / N Items( colorlist ), 3 ) * 100 ) || "%)." ); Wait( 0 );, i == N Items( colorlist ), Caption( "Data Table Populated" ); Wait( 1 ); Caption( Remove ); Wait( 0 ); ); ); :Color << Eval Formula; :Red << Eval Formula; :Green << Eval Formula; :Blue << Eval Formula; :Brightness << Eval Formula; dt << Set Dirty(0); dt << Run Script( "Ternary Plot" ) << Run Script( "Scatter Plot 3D" );