Skip to content

Instantly share code, notes, and snippets.

@facelessuser
Last active May 25, 2023 13:01
Show Gist options
  • Save facelessuser/99b49304adeccfc0ed83da6eeebd2818 to your computer and use it in GitHub Desktop.
Save facelessuser/99b49304adeccfc0ed83da6eeebd2818 to your computer and use it in GitHub Desktop.
Random Harmonies

Random color harmony generator.

Available harmonies are:

Harmony Description
mono Monochromatic
complement Complementary
split Split Complementary
analogous Analogous
triad Triadic
square Tetradic Square
rectangle Tetradic Rectangular

If you prefer a specific harmony, just replace harmony = harmonies[index] with harmony = 'harmony-name' with harmony-name with replaced with the desired harmony from the table above.

import random

index = random.randrange(0, 7)
harmonies = ['mono', 'complement', 'split', 'analogous', 'triad', 'square', 'rectangle']
harmony = harmonies[index]
print(f'=== Chosen Harmony is {harmony} ===')

HtmlSteps([i.to_string(hex=True) for i in Color.random('srgb').harmony(harmony, space='okhsl', out_space='srgb')])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment