Skip to content
Browse files

Added some comments to stylesheet generation.

  • Loading branch information...
1 parent 9f33b9b commit 217be9ba5f20791a6bebb0071aecaf4030f98615 @xenomachina committed
Showing with 5 additions and 2 deletions.
  1. +5 −2 art/primes/primes.py
View
7 art/primes/primes.py
@@ -113,12 +113,15 @@ def printStylesheet(prime_to_color):
'''
# We want a diverse palette, so evenly divide a Hilbert curve for RGB
- # space.
+ # space. This is inspired by (and uses code from)
+ # http://corte.si/posts/visualisation/binvis/index.html
num_colors = max(prime_to_color.values()) + 1
hilbert = scurve.fromSize('hilbert', 3, RGB_SIZE)
colors = [hilbert[i] for i in range(0, RGB_SIZE, RGB_SIZE // num_colors)]
+
# We also want numbers that are close to each other to have very
- # different colors, so phiffle the colors.
+ # different colors, so phiffle the colors, and convert to CSS-friendly
+ # form while we're at it.
colors = ['#%02x%02x%02x' % (r,g,b) for (r,g,b) in phiffle(colors)]
for prime, color in sorted(prime_to_color.items()):

0 comments on commit 217be9b

Please sign in to comment.
Something went wrong with that request. Please try again.