in reply to What's up with the RGB method?
Taking a stab in the dark...
It may be that the colours are on a 48-bit scale in stead of 24-bit; that is, 16 bits are available for each channel (red, green, and blue).
This is becoming increasingly common in anticipation of 48-bit consumer-level hardware, ie: pretty soon you'll actually need the extra bits, and be glad that they're there.
If this is the case here (but I don't know Tk, so YMMV), the range would be 0..65535; everything else should remain unchanged. Try grabbing $widget->rgb('white') and $widget->rgb('black'), and using their triplets as the limits of your sliders:
something like...
my %colour_min, %colour_max; @colour_min{ 'red', 'green', 'blue' } = $widget->rgb('black'); @colour_max{ 'red', 'green', 'blue' } = $widget->rgb('white'); # ... my %triplet; @triplet{ 'red', 'green', 'blue' } = $widget->rgb($user_entry); my %slider; # 0..1 range [eg. 50% grey might be (.5,.5,.5) ] for my $channel ('red', 'green', 'blue') { $slider{$channel} = ( $triplet{$channel} - $colour_min{$channel} ) / + ( $colour_max{$channel} / $colour_min{$channel} ) ); }
That's probably overkill, though, since you can generally assume that black will be (0,0,0), which reduces the final block to
for my $channel ('red', 'green', 'blue') { $slider{$channel} = $triplet{$channel} / $colour_max{$channel}; }
There's also probably a right way to do this that I don't know about... :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: What's up with the RGB method?
by Anonymous Monk on Mar 28, 2001 at 02:30 UTC |