Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Based on Math behind Colourspace Conversions, I was able to at least sort the colours:
#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; sub hue { my ($colour) = @_; my %rgb; @rgb{qw{ red green blue }} = map hex($_) / 255, $colour =~ /^#(..) +(..)(..)/; my @order = sort { $rgb{$a} <=> $rgb{$b} } keys %rgb; my $hue = {red => sub { 0 + $rgb{green} - $rgb{blue}}, green => sub { 2 + $rgb{blue} - $rgb{red} }, blue => sub { 4 + $rgb{red} - $rgb{green} } }->{ $order[2] }->(); my $d = $rgb{ $order[2] } - $rgb{ $order[0]}; return 0 if 0 == $d; $hue /= $d; $hue *= 60; $hue += 360 if $hue < 0; return $hue } my @colours = do { no warnings 'qw'; qw( #000000 #716373 #704A2B #AF7E45 #963049 #AA2261 #B24551 #E6212E #FF0000 #001200 #FFDE72 #F55B73 + ) }; my %hue = map { $_ => hue($_) } @colours; my @sorted = sort { $hue{$a} <=> $hue{$b} } keys %hue; say "@sorted";
The black/white problem is not solved here, so feel free to expand as you need.
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

In reply to Re: Ordering Colours Problem by choroba
in thread Ordering Colours Problem by merrymonk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-03-29 01:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found