sharkdp / pastel

A command-line tool to generate, analyze, convert and manipulate colors
Apache License 2.0
5.07k stars 102 forks source link

Add sort-by-binary-operation subcommand #178

Closed veryaery closed 1 year ago

veryaery commented 1 year ago

This PR adds a new subcommand: sort-by-binary-operation. The command takes a required binary operation argument, a single required operand color argument, and an optional list of colors. It then sorts the list of colors by the result of applying the given binary operation with the given operand color.

For example: pastel sort-by-binary-operation distance #ff4500 red orange Would act as:

sort [ distance(#ff4500, red)
     , distance(#ff4500, orange)
     ]

And you would come to find that the color of Reddit upvotes are indeed closer perceived as red than orange.

This is the list of binary operation options:

They are the orderable binary operations of Color.

Some use cases are: