Easy methods to Convert a Single HEX Colour Code right into a Monochrome Colour Palette with Python | by Dario Radečić | Sep, 2024


Spoiler: It’s tougher than you assume.

Article thumbnail (picture by writer)

Colours are laborious, particularly should you don’t have an eye fixed for design.

Most of us tech professionals don’t. The upside is that Python can do a lot of the heavy lifting for you. It might probably generate a complete monochromatic colour palette that’ll look gorgeous on any stacked chart.

The draw back is that getting there requires a good bit of coding. It’s a must to write customized capabilities to transform a colour from HEX to HSL and vice versa, and determine if the beginning colour is simply too shiny, in addition to how a lot lighter every subsequent colour ought to be.

Including insult to harm, I haven’t discovered a single absolutely working Python library able to engaging in this activity.

That’s the place this text chimes in.

In case you’re a subscriber to my Substack, you possibly can skip the studying and download the notebook as an alternative.

Let’s rapidly cowl three colour codecs it is advisable to know:

  • HEX — A six-digit code usually utilized in internet growth and graphic design. The colour code begins with a #, adopted by six hexadecimal digits. Pairs…

Leave a Reply

Your email address will not be published. Required fields are marked *