On Sep 20, 10:30 am, Dick Jackson <d...@d-jackson.com> wrote:
> On Sep 20, 9:33 am, David Fanning <n...@dfanning.com> wrote:
>
>> wlandsman writes:
>>> I assume it is
>
>>> IDL> help,/str,!color
>
>> Ah, I tried this:
>
>> IDL> Print, !Color
>
>> Should have known better. Thanks!
>
> And possibly more convenient:
>
> IDL> Print, Tag_Names(!Color)
I see the !Color structure, with colour names as tag names, as less
than ideal. To get at the colour triples, you have to use a FOR loop
and dig into Advanced Structure Usage:
IDL> rgb=Bytarr(3, n_tags(!color))
IDL> for i=0,n_tags(!color)-1 do rgb[0,i]=(!color).(i)
IDL> tv,/true,rebin(rgb,[3,n_tags(!color)*4,50],/Sample) ; Show
swatches
To be more useful, it should have been initialized something like:
!ColorHandy = [{NAME: 'ALICE_BLUE', RGB: [240B, 248B, 255B]}, {...}]
Then you could get !ColorHandy.name for all the names, !ColorHandy.rgb
for the [3, 147] array.
I've written a routine to make a !ColorHandy variable (suitable for
inclusion in your startup file, or IDL's kernel, depending on your
influence :-)... you're welcome to it, all rights absolved.
PRO InitColorHandy
; Makes system variable !ColorHandy, an array of structures, from
information
; extracted from !Color.
; - N_Elements(!ColorHandy) is the number of colors
; - !ColorHandy.name is StrArr(nColors) containing all the names
; - !ColorHandy.rgb is Bytarr(3, nColors) the RGB array.
nColors = N_Tags(!Color)
rgb = BytArr(3, nColors)
FOR colorI=0, nColors-1 DO rgb[0, colorI] = (!Color).(colorI)
DefSysV, '!COLORHANDY', Replicate({Name: '', RGB: BytArr(3)}, nColors)
!ColorHandy.name = Tag_Names(!Color)
!ColorHandy.rgb = rgb
END
Once this is run, the following is possible in one line:
IDL> tv,/true,rebin(!colorhandy.rgb,[3,n_elements(!colorhandy)*4, 50],/
Sample) ; Show swatches
Cheers,
-Dick
Dick Jackson Software Consulting
Victoria, BC, Canada
www.d-jackson.com
|