U
U
Urukhayy2016-08-13 15:00:10
Programming
Urukhayy, 2016-08-13 15:00:10

Where or how can this be organized (working with flowers)?

There is an array of colors in hexadecimal notation:

0x000000FF, 0xF5F5F5FF, 0x2A77A1FF, 0x840410FF, 0x263739FF, 0x86446EFF, 0xD78E10FF, 0x4C75B7FF, 0xBDBEC6FF, 0x5E7072FF,
0x46597AFF, 0x656A79FF, 0x5D7E8DFF, 0x58595AFF, 0xD6DAD6FF, 0x9CA1A3FF, 0x335F3FFF, 0x730E1AFF, 0x7B0A2AFF, 0x9F9D94FF,
0x3B4E78FF, 0x732E3EFF, 0x691E3BFF, 0x96918CFF, 0x515459FF, 0x3F3E45FF, 0xA5A9A7FF, 0x635C5AFF, 0x3D4A68FF, 0x979592FF,
0x421F21FF, 0x5F272BFF, 0x8494ABFF, 0x767B7CFF, 0x646464FF, 0x5A5752FF, 0x252527FF, 0x2D3A35FF, 0x93A396FF, 0x6D7A88FF

We need the program to sort these colors in the order given in the color spectrum (rainbow). Maybe there are ready-made services?
Or, to be sorted according to a different spectrum, but with a smooth transition from color to color.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexander Skusnov, 2016-08-14
@Urukhayy

Make the transition RGB -> HSV and sort by H (hue - color tone).

D
dom1n1k, 2016-08-13
@dom1n1k

This task does not have a unique solution, because there are three color coordinates, and the array is one-dimensional.
Here is an article just about this:
https://habrahabr.ru/company/yandex/blog/263375/

R
riot26, 2016-08-13
@riot26

on js:
https://stackoverflow.com/a/25916085

F
Fat Lorrie, 2016-08-13
@Free_ze

  1. Take the colors of the rainbow (as you know - K-O-F-Z-G-S-F)
  2. sort the points of the original array by them (find the Cartesian distance between the point and the pure base color), we get a fairly simple two-dimensional palette: the base color and the distance to it,
  3. reduce it to a one-dimensional array: display the groups in natural order, and the colors in each group in ascending distance.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question