No recent polls found
Perl Monk, Perl Meditation | |
PerlMonks |
merrymonk has asked for the wisdom of the Perl Monks concerning the following question:
|
---|
Replies are listed 'Best First'. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Re: Ordering Colours Problem
by choroba (Cardinal) on Mar 05, 2021 at 12:47 UTC | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
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]
| [reply] [d/l] [select] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: Ordering Colours Problem
by johngg (Canon) on Mar 05, 2021 at 12:10 UTC | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
As LanX says, there's all kinds of colour wheels. This page has an interesting interactive colour wheel that, when played around with, illustrates how tricky your problem is. I'm guessing that some maths to convert RGB values into angular values based on proportion would be a starting point but you then have the white/black question to resolve, which adds the third dimension. Cheers, JohnGG | [reply] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: Ordering Colours Problem
by vr (Curate) on Mar 06, 2021 at 18:18 UTC | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
Colour value is a point in 3d space, how would you "order" these points along (which?) single axis? That said, the "ordering" can be considered as TSP, where simple greedy nearest neighbour algorithm and arbitrarily/heuristically chosen starting point (black) produce "good enough" result. (The fact that black is among source colours (moreover, first) is irrelevant -- root isn't included in solution) Here are 5 colour ramps: Well, how much scientific ramp is more "pleasing" is in the eye of beholder :). Maybe dumb NN is limiting factor here.
Edit: s/Through/Throw/ :) | [reply] [d/l] [select] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
by choroba (Cardinal) on Mar 06, 2021 at 22:54 UTC | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
If you run my code several times, you'll see the black and red are sometimes swapped. That's because black is in fact the darkest possible red :-)
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
| [reply] [d/l] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
by vr (Curate) on Mar 07, 2021 at 07:53 UTC | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
Oh, I see: sort is performed on keys of derived hash, not original list. Hence the unstable result. | [reply] [d/l] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
by LanX (Saint) on Mar 07, 2021 at 01:13 UTC | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
While height is (L)umidity, does the distance to the circles center represent (S)aturation. The axis of that cylinder, the circles center (S=0) is the gray-scale, with black at the bottom (L=0) and white at the top (L=1) and belongs to all "colors" of that wheel. I.e one point on the wheel represents all colors in the rectangle formed by axis and angle. (The side of a cakepiece) Crazy!
Cheers Rolf | [reply] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: Ordering Colours Problem
by LanX (Saint) on Mar 05, 2021 at 11:50 UTC | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
So use sort or put more effort into your questions
Cheers Rolf °) eg there is no black on the wheel!!!! | [reply] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: Ordering Colours Problem
by kcott (Archbishop) on Mar 07, 2021 at 13:55 UTC | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
G'day merrymonk, I saw this on Friday and couldn't think of a better answer than ++choroba's post. However, today (Sunday) I saw a spectrum presented as various shades of:
If something along those lines suits your purpose, you can pull out, and possibly modify, parts of the following code, to get your desired result.
As you can see, I added a separate array of evenly-spaced colours (mainly for my own testing purposes). The output, from print_table(), is PM-style HTML which I pasted directly into my post. With my test colours, I got the result I was looking for:
Using the colours from your OP, the result is possibly not what you're after:
Some observations:
"how to order these so that they are in the same order as the colours found on a normal colour wheel" If you told us what you believe the "normal colour wheel" order is, we would then at least know the expected results, and could potentially provide better answers. This general problem-space is interesting. I've front-paged this question to perhaps gain a wider coverage. It would be particularly useful if you would provide feedback to the responses you've received. — Ken | [reply] [d/l] [select] |