Last active
December 18, 2018 23:39
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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