Skip to main content

Small library for color conversion, manipulation, etc.

Project description

repacolors

Small library for color conversion, manipulation, etc.

Build Status

demo

Install

$ pip install repacolors

To get the colors from Xrdb, install it with the xextras extras:

$ pip install repacolors[xextras]

repacolor command

$ repacolor --help
Usage: repacolor [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  adjust-contrast  Adjust the colors to match required contrast ratio.
  colorwheel       Display colorwheel defined by `name` or created by the...
  display          Display information about the provided colors.
  palette          Get colors of given palette
  pick             Pick colors from your desktop.
  scale            Display color scale defined by the colors provided.

display

Display color information in the terminal.

$ repacolor display red

+--------+ red - #ff0000
|  BIG   | rgb(255, 0, 0)
|  RED   | hsl(0, 100%, 50%)
| SQUARE | lab(53.24% 80.09 67.2)
+--------+

$ repacolor display "#ffaad5" "rgb(128, 12, 46, .8)"
... (displays both colors)
$ echo "#ffffff" | repacolor display
... (displays `white`)

pick

Executes color picker and displays the picked color.

$ repacolor pick

The integrated color picker works under X11/linux if installed with xextras. If you want to use an external color picker, set the COLORPICKER environment variable:

$ export COLORPICKER=xcolor
$ repacolor pick

palette

Display the colors of the palette. If no palette name provided, it shows the palettes available.

$ repacolor palette
List of available palette names:
ryb, rybw3, orrd, pubu, ...

$ repacolor palette viridis
#440154
#482777
...

scale

Display a color scale defined by the input colors.

$ repacolor scale red white
[colors from red to white]
$ repacolor palette viridis | repacolor scale
[color scale defined by `viridis` colors]

colorwheel

Display a color wheel.

Pre defined color wheels:

  • ryb - The RYB color wheel
  • rgb or hsl - The RGB color wheel
  • lab or lch - CIELAB color wheel

If no color wheel name provided, it will create one from the colors provided on stdin.

$ repacolor colorwheel rgb
[RGB color wheel]
$ repacolor scale red white black red | repacolor colorwheel
[red - white - black color wheel]

adjust-contrast

Adjust the colors to match required contrast ratio.

If only one color is provided, chooses black or white based on the colors luminance.

If two colors are provided, tries to lighten/darken them to fulfill the contrast requirement. Starts to adjust the first color, then if it's not enough continues with the other.

Default contrast is 4.5 (WCAG AA). More info on MDN.

$ repacolor adjust-contrast red --format=lhex
#ff0000
#000000  # chooses black for red
$ repacolor adjust-contrast "#555" "#5e8d87" --format=lhex
#1d1d1d  # #555 adjusted to be darker
#5e8d87
$ repacolor adjust-contrast "#5e8d87" "#555" --format=lhex
#b6cfcc  # #5e8d87 lightened
#555555
$ repacolor adjust-contrast "#5e8d87" "#555" -v
Colors adjusted. (2.0007 => 4.5224)
  #5e8d87   =>   #b6cfcc
  #555555   =>   #555555

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

repacolors-0.8.0.tar.gz (33.2 kB view details)

Uploaded Source

Built Distribution

repacolors-0.8.0-py3-none-any.whl (36.0 kB view details)

Uploaded Python 3

File details

Details for the file repacolors-0.8.0.tar.gz.

File metadata

  • Download URL: repacolors-0.8.0.tar.gz
  • Upload date:
  • Size: 33.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.5 CPython/3.9.2 Linux/5.11.11-arch1-1

File hashes

Hashes for repacolors-0.8.0.tar.gz
Algorithm Hash digest
SHA256 bf6db17bf992f844c741b0ceee4641a6fc26843fe3108cadb98c4a21f8cbf48f
MD5 c1e7f39ad77ec9fb52d7fe4a13a8ea26
BLAKE2b-256 d74a59181ac4d769ad848a47df7821640b74b03e24d238f55ac4246876fca05e

See more details on using hashes here.

File details

Details for the file repacolors-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: repacolors-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 36.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.5 CPython/3.9.2 Linux/5.11.11-arch1-1

File hashes

Hashes for repacolors-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9cf02f2ddf09448efa7aebfdb399bd7e0b07d4b3a114a04f69eda76a18433544
MD5 9450c0e897038f8414d37c1c3957ad6e
BLAKE2b-256 fb804fa2378e3d1913d0539f6b0cbd4fdf94909d09939d9782bd46949f122064

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page