Date[]

MyGraphicsColors Palette
- development notebook -

Jack_Calman@jhuapl.edu
 with TechSupport help from William Austin (WRI)

Load Colors

<< Graphics`Colors`

thecolors  =  
        Drop[Names["Graphics`Colors`*"],  {3}] ;

n  =  Length[thecolors]

Colors in Alphabetical Order

mydata  =  
        Table[ButtonBox[" ", 
            ButtonData :> Evaluate[ToString[thecolors[[i]]]], 
            Background -> ToExpression[thecolors[[i]]], 
            ButtonNote -> thecolors[[i]]], {i, n}];

mydata  =  
        Partition[
          Flatten[AppendTo[
              mydata, {ButtonBox[" ", 
                  ButtonData :> 
                    Evaluate[ToString[thecolors[[n]]]], 
                  Background -> ToExpression[thecolors[[n]]], 
                  ButtonNote -> thecolors[[n]]], 
                ButtonBox[" ", 
                  ButtonData :> 
                    Evaluate[ToString[thecolors[[n]]]], 
                  Background -> ToExpression[thecolors[[n]]], 
                  ButtonNote -> thecolors[[n]]]}]], 6];

Cell[
        BoxData[GridBox[mydata
, RowSpacings -> 0, 
            ColumnSpacings -> 0, ColumnWidths -> 1.7, 
            ColumnAlignments -> {Center}, RowMinHeight -> 1.3, 
            RowsEqual -> True, ColumnsEqual -> True]], 
        NotebookDefault, 
        CellMargins -> {{Inherited, Inherited}, {5, Inherited}}, 
        Evaluatable -> True, 
        CellGroupingRules -> "InputGrouping", 
        CellHorizontalScrolling -> True, PageBreakAbove -> True, 
        PageBreakWithin -> False, GroupPageBreakWithin -> False, 
        GeneratedCell -> True, 
        CellLabelMargins -> {{23, Inherited}, {Inherited, Inherited}}, 
        DefaultFormatType -> DefaultInputFormatType, 
        LineSpacing -> {1.25, 0}, AutoItalicWords -> {}, 
        FormatType -> InputForm, ScriptMinSize -> 9, 
        ShowStringCharacters -> True, NumberMarks -> True, 
        CounterIncrements -> "Input", StyleMenuListing -> None, 
        FontFamily -> "Helvetica", FontSize -> 10, 
        FontWeight -> "Plain"] // CellPrint

Sorted Colors (development)

get {name, rgb} for rgb colors for sorting the palette by color

c  =  
        Sort[Transpose[{ToExpression  /@  thecolors,  
              thecolors}]];

TableForm[c,  
      TableHeadings  ->  {Automatic,  None}]

c  = 
        Select[c,  
          Head[#[[1]]]  ==  RGBColor  &];

sortedcolors  =  #[[2]] &  /@  c

non rbg colors

thecolors  =  sortedcolors;
n  =  Length[thecolors];

mydata  =  
        Table[ButtonBox[" ", 
            ButtonData :> Evaluate[ToString[thecolors[[i]]]], 
            Background -> ToExpression[thecolors[[i]]], 
            ButtonNote -> thecolors[[i]]], {i, n}];

mydata  =  
        Partition[
          Flatten[AppendTo[
              mydata, {ButtonBox[" ", 
                  ButtonData :> 
                    Evaluate[ToString[thecolors[[n]]]], 
                  Background -> ToExpression[thecolors[[n]]], 
                  ButtonNote -> thecolors[[n]]], 
                ButtonBox[" ", 
                  ButtonData :> 
                    Evaluate[ToString[thecolors[[n]]]], 
                  Background -> ToExpression[thecolors[[n]]], 
                  ButtonNote -> thecolors[[n]]]}]], 6];

Cell[
        BoxData[GridBox[mydata
, RowSpacings -> 0, 
            ColumnSpacings -> 0, ColumnWidths -> 1.7, 
            ColumnAlignments -> {Center}, RowMinHeight -> 1.3, 
            RowsEqual -> True, ColumnsEqual -> True]], 
        NotebookDefault, 
        CellMargins -> {{Inherited, Inherited}, {5, Inherited}}, 
        Evaluatable -> True, 
        CellGroupingRules -> "InputGrouping", 
        CellHorizontalScrolling -> True, PageBreakAbove -> True, 
        PageBreakWithin -> False, GroupPageBreakWithin -> False, 
        GeneratedCell -> True, 
        CellLabelMargins -> {{23, Inherited}, {Inherited, Inherited}}, 
        DefaultFormatType -> DefaultInputFormatType, 
        LineSpacing -> {1.25, 0}, AutoItalicWords -> {}, 
        FormatType -> InputForm, ScriptMinSize -> 9, 
        ShowStringCharacters -> True, NumberMarks -> True, 
        CounterIncrements -> "Input", StyleMenuListing -> None, 
        FontFamily -> "Helvetica", FontSize -> 10, 
        FontWeight -> "Plain"] // CellPrint

Sort Colors by RGB^2 Value & Evaluate When Clicked

c  =  
        Select[Transpose[{ToExpression  /@  thecolors,  thecolors}],  
          Head[#[[1]] ] ==  RGBColor  &];

c  // TableForm

x  = ( #[[1, 1]]^2  +  #[[1, 2]]^2 + #[[1, 
                      3]]^2)  &    /@   c ;

valuesort  =  
      Sort[MapThread[Flatten[{#1,  #2}] &,  {x, c}]]

thecolors  =  Last  /@  valuesort;
n  =  Length[thecolors];

mydata  =  
        Table[ButtonBox[" ", 
            ButtonData :> Evaluate[ToString[thecolors[[i]]]], 
            Background -> ToExpression[thecolors[[i]]], 
            ButtonNote -> thecolors[[i]],  
            ButtonStyle  ->  "Evaluate"], {i, n}];

mydata  =  
        Partition[
          Flatten[AppendTo[
              mydata, {ButtonBox[" ", 
                  ButtonData :> 
                    Evaluate[ToString[thecolors[[n]]]], 
                  Background -> ToExpression[thecolors[[n]]], 
                  ButtonNote -> thecolors[[n]],  
                  ButtonStyle  ->  "Evaluate"], 
                ButtonBox[" ", 
                  ButtonData :> 
                    Evaluate[ToString[thecolors[[n]]]], 
                  Background -> ToExpression[thecolors[[n]]], 
                  ButtonNote -> thecolors[[n]],  
                  ButtonStyle  ->  "Evaluate"]}]], 
          6];

Cell[
        BoxData[GridBox[mydata
, RowSpacings -> 0, 
            ColumnSpacings -> 0, ColumnWidths -> 1.7, 
            ColumnAlignments -> {Center}, RowMinHeight -> 1.3, 
            RowsEqual -> True, ColumnsEqual -> True]], 
        NotebookDefault, 
        CellMargins -> {{Inherited, Inherited}, {5, Inherited}}, 
        Evaluatable -> True, 
        CellGroupingRules -> "InputGrouping", 
        CellHorizontalScrolling -> True, PageBreakAbove -> True, 
        PageBreakWithin -> False, GroupPageBreakWithin -> False, 
        GeneratedCell -> True, 
        CellLabelMargins -> {{23, Inherited}, {Inherited, Inherited}}, 
        DefaultFormatType -> DefaultInputFormatType, 
        LineSpacing -> {1.25, 0}, AutoItalicWords -> {}, 
        FormatType -> InputForm, ScriptMinSize -> 9, 
        ShowStringCharacters -> True, NumberMarks -> True, 
        CounterIncrements -> "Input", StyleMenuListing -> None, 
        FontFamily -> "Helvetica", FontSize -> 10, 
        FontWeight -> "Plain"] // CellPrint

Sort Colors by RGB Value

c  =  
        Select[Transpose[{ToExpression  /@  thecolors,  thecolors}],  
          Head[#[[1]] ] ==  RGBColor  &];

c  // TableForm

x  = ( #[[1, 1]]  +  #[[1, 2]] + #[[1, 
                    3]])  &    /@   c;

valuesort  =  
      Sort[MapThread[Flatten[{#1,  #2}] &,  {x, c}]]

thecolors  =  Last  /@  valuesort;
n  =  Length[thecolors];

mydata  =  
        Table[ButtonBox[" ", 
            ButtonData :> Evaluate[ToString[thecolors[[i]]]], 
            Background -> ToExpression[thecolors[[i]]], 
            ButtonNote -> thecolors[[i]]], {i, n}];

mydata  =  
        Partition[
          Flatten[AppendTo[
              mydata, {ButtonBox[" ", 
                  ButtonData :> 
                    Evaluate[ToString[thecolors[[n]]]], 
                  Background -> ToExpression[thecolors[[n]]], 
                  ButtonNote -> thecolors[[n]]], 
                ButtonBox[" ", 
                  ButtonData :> 
                    Evaluate[ToString[thecolors[[n]]]], 
                  Background -> ToExpression[thecolors[[n]]], 
                  ButtonNote -> thecolors[[n]]]}]], 6];

Cell[
        BoxData[GridBox[mydata
, RowSpacings -> 0, 
            ColumnSpacings -> 0, ColumnWidths -> 1.7, 
            ColumnAlignments -> {Center}, RowMinHeight -> 1.3, 
            RowsEqual -> True, ColumnsEqual -> True]], 
        NotebookDefault, 
        CellMargins -> {{Inherited, Inherited}, {5, Inherited}}, 
        Evaluatable -> True, 
        CellGroupingRules -> "InputGrouping", 
        CellHorizontalScrolling -> True, PageBreakAbove -> True, 
        PageBreakWithin -> False, GroupPageBreakWithin -> False, 
        GeneratedCell -> True, 
        CellLabelMargins -> {{23, Inherited}, {Inherited, Inherited}}, 
        DefaultFormatType -> DefaultInputFormatType, 
        LineSpacing -> {1.25, 0}, AutoItalicWords -> {}, 
        FormatType -> InputForm, ScriptMinSize -> 9, 
        ShowStringCharacters -> True, NumberMarks -> True, 
        CounterIncrements -> "Input", StyleMenuListing -> None, 
        FontFamily -> "Helvetica", FontSize -> 10, 
        FontWeight -> "Plain"] // CellPrint

Another Sort & Evaluate When Clicked

c  =  
        Select[Transpose[{ToExpression  /@  thecolors,  thecolors}],  
          Head[#[[1]] ] ==  RGBColor  &];

c  // TableForm

rms  =  Sqrt[( #[[1, 1]]^2  +  #[[1, 
                        2]]^2 + #[[1, 
                        3]]^2)]  &    /@   c;

{x, y, z}  =  
      Transpose[{#[[1, 1]],  #[[1, 2]],  #[[1, 3]]}/
              Sqrt[( #[[1, 1]]^2  +  #[[1, 2]]^2 + #[[1, 
                          3]]^2)]  &  /@  c]

valuesort  =  
      Sort[MapThread[
          Flatten[{#1,  #2, #3, #4}] &,  {x, y, z, c}]]

thecolors  =  Last  /@  valuesort;
n  =  Length[thecolors];

mydata  =  
        Table[ButtonBox[" ", 
            ButtonData :> Evaluate[ToString[thecolors[[i]]]], 
            Background -> ToExpression[thecolors[[i]]], 
            ButtonNote -> thecolors[[i]],  
            ButtonStyle  ->  "Evaluate"], {i, n}];

mydata  =  
        Partition[
          Flatten[AppendTo[
              mydata, {ButtonBox[" ", 
                  ButtonData :> 
                    Evaluate[ToString[thecolors[[n]]]], 
                  Background -> ToExpression[thecolors[[n]]], 
                  ButtonNote -> thecolors[[n]],  
                  ButtonStyle  ->  "Evaluate"], 
                ButtonBox[" ", 
                  ButtonData :> 
                    Evaluate[ToString[thecolors[[n]]]], 
                  Background -> ToExpression[thecolors[[n]]], 
                  ButtonNote -> thecolors[[n]],  
                  ButtonStyle  ->  "Evaluate"]}]], 
          6];

Cell[
        BoxData[GridBox[mydata
, RowSpacings -> 0, 
            ColumnSpacings -> 0, ColumnWidths -> 1.7, 
            ColumnAlignments -> {Center}, RowMinHeight -> 1.3, 
            RowsEqual -> True, ColumnsEqual -> True]], 
        NotebookDefault, 
        CellMargins -> {{Inherited, Inherited}, {5, Inherited}}, 
        Evaluatable -> True, 
        CellGroupingRules -> "InputGrouping", 
        CellHorizontalScrolling -> True, PageBreakAbove -> True, 
        PageBreakWithin -> False, GroupPageBreakWithin -> False, 
        GeneratedCell -> True, 
        CellLabelMargins -> {{23, Inherited}, {Inherited, Inherited}}, 
        DefaultFormatType -> DefaultInputFormatType, 
        LineSpacing -> {1.25, 0}, AutoItalicWords -> {}, 
        FormatType -> InputForm, ScriptMinSize -> 9, 
        ShowStringCharacters -> True, NumberMarks -> True, 
        CounterIncrements -> "Input", StyleMenuListing -> None, 
        FontFamily -> "Helvetica", FontSize -> 10, 
        FontWeight -> "Plain"] // CellPrint