Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make sure that areas with the same name have the same colour

The simplest way to do this is to reseed the random number generator
based on the name of the area before picking a random hue.
  • Loading branch information...
commit 804d1a7d119dcf02e7614353436c9cf1f1d1c111 1 parent fdd2a50
@mhl mhl authored
Showing with 2 additions and 1 deletion.
  1. +2 −1  mapit/management/commands/mapit_make_fusion_csv.py
View
3  mapit/management/commands/mapit_make_fusion_csv.py
@@ -54,7 +54,7 @@
import sys
import csv
from optparse import make_option
-from random import random
+from random import random, seed
import colorsys
from django.core.management.base import BaseCommand
@@ -140,6 +140,7 @@ def handle(self, *args, **options):
writer = csv.writer(fp)
writer.writerow(["name", "color", "location"])
for i, area in enumerate(areas):
+ seed(area.name)
hue = random()
line_rgb = rgb_for_html(*hsv_to_rgb(hue, 0.5, 0.5))
fill_rgb = rgb_for_html(*hsv_to_rgb(hue, 0.5, 0.95))
Please sign in to comment.
Something went wrong with that request. Please try again.