rvdz / hapycolor

Generates beautiful color palettes from images
MIT License
3 stars 0 forks source link

Vim casting #18

Closed nyancol closed 5 years ago

nyancol commented 6 years ago

This pull request introduces new clever algorithm to cast the colors of the generated palette to vim's syntactic groups, it features:

I advice you to review the three previous pull request before starting this one.

The clustering algorithm could be useful for other purposes, such as terminal color casting (or lightline, yabar ...). For instance, the colors could be first classified into K clusters, K standing for the number of colors that can be affected to a terminal profile, and then use the medoids of each cluster as the color.

romzie commented 6 years ago

Even when clustered, how do you choose the final color of a cluster? If you have 16 colors required for terminal, that's 16 clusters, then how do you suggest we decide which color is the one?

nyancol commented 6 years ago

Indeed, that is why I used a k-medoid classification, so that each cluster is defined by a center, that is also a real color taken from the color's list.

nyancol commented 6 years ago

One cluster of colors is selected for each major syntactic group (e.g., Statement is a major syntactic group, that contains: Conditional, Repeat etc.), and then colors from the cluster are mapped to the subgroups of the group. My idea was that if and for should have similar hues. But know that I think of it, that might not be true for Constant, which includes String, Character, Number, etc. Any thoughts?

nyancol commented 6 years ago

Here's the list: Vim syntaxV

romzie commented 6 years ago

Yes I was mostly thinking about the Constant group, and the difference between string and numbers and booleans

nyancol commented 6 years ago

Do splitting the Constant group into: [[String, Character], [Constant, Number, Float], [Boolean]] would be enough to overcome this issue?