Skip to content

Instantly share code, notes, and snippets.

@amueller
Last active April 20, 2024 01:38
Show Gist options
  • Save amueller/6638061 to your computer and use it in GitHub Desktop.
Save amueller/6638061 to your computer and use it in GitHub Desktop.
random color palette using halton codes
def halton(index, base):
result = 0
f = 1. / base
i = index
while(i > 0):
result = result + f * (i % base)
i = np.floor(i / base)
f = f / base
return result
def get_color(i=0):
# starting with i ~ 10 might yield better results.
while True:
c1 = halton(i, 2)
c2 = halton(i, 3)
c3 = halton(i, 5)
i += 1
yield [c1, c2, c3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment