comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Colors in Function Graphics?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Colors in Function Graphics? [message #77745] Tue, 20 September 2011 11:36 Go to previous message
Dick Jackson is currently offline  Dick Jackson
Messages: 347
Registered: August 1998
Senior Member
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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Colors in Function Graphics?
Next Topic: Call_Function() fail?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 02:21:21 PDT 2025

Total time taken to generate the page: 0.40268 seconds