Skip to content

Instantly share code, notes, and snippets.

@stephencweiss
Last active December 18, 2018 23:39
Show Gist options
  • Save stephencweiss/b81534a759c7e6cc7b6feed83df38874 to your computer and use it in GitHub Desktop.
Save stephencweiss/b81534a759c7e6cc7b6feed83df38874 to your computer and use it in GitHub Desktop.
A ruby snippet for generating random colors using the golden ratio. Credit: Martin Ankerl
# Credit: Martin Ankerl: How to Generate Random Colors Programmatically
# Source: https://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically/
# use golden ratio
golden_ratio_conjugate = 0.618033988749895
h = rand # use random start value
gen_html {
h += golden_ratio_conjugate
h %= 1
hsv_to_rgb(h, 0.5, 0.95)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment