Skip to content

ViniciusJO/color_juicer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Color juicer

Uses the k-means algorithm to extract colors from image.

Made using stb_image utilities;

It is extremly opinionated to get the most brigth colors to contrast with the black background of my polybar. The code also calculates the color that most contrast with the ones extracted, in order to use as accent in the system.

# The result is not deterministic !!!

Configured to generate the following files:

  • $HOME/.cache/dyn_colors.ini: to use in polybar (exposes colors pprim, psec, pterc, pcont);
  • $HOME/.cache/i3_colors: to configure the borders of focused containers in i3 with the color that most contrast with the extracted ones

Usage

color_juicer <img_path> <centroids> <downsampling_factor>
  • img_path: path to the image location in file system
  • centroids: number of centroids generated
  • downsampling_factor: factor to reduce the image resolution

Output example

For the image test.png:

test.png

color_juicer test.png 5 5 extracts:

#ecd5a5 #427b92 #ada58c #716365

  • pprim: #ecd5a5 #ecd5a5
  • psec: #427b92 #427b92
  • pterc: #ada58c #ada58c
  • pcont: #716365 #716365

and generates:

  • on console
pprim: #ECD5A5
psec:  #427B92
pterc: #ADA58C
pcont: #716365
  • on $HOME/.cache/dyn_colors.ini:
[dyn_colors]
pprim = #ECD5A5
psec = #427B92
pterc = #ADA58C
pcont = #716365
cprim = #C7A795
csec = #5A6387
  • on $HOME/.cache/i3_colors:
client.focused #716365 #716365 #000000 #ECD5A5 #716365

TBD:

  • Cleanup code
  • Generate files to stylize:
    • rofi
    • dunst
    • gtk
    • qt

About

Extract color palette from image.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published