Pārlūkot izejas kodu

Improve random color logic, add shebang

Kirk Trombley 3 gadi atpakaļ
vecāks
revīzija
a77bd4eca2
1 mainītis faili ar 3 papildinājumiem un 3 dzēšanām
  1. 3 3
      nearest.py

+ 3 - 3
nearest.py

@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
 import csv
 import colorsys
 import random
@@ -18,9 +19,8 @@ if args.color is not None:
         raise ValueError("Color must be a 6 digit hex")
     color = (int(args.color[0:2], base=16), int(args.color[2:4], base=16), int(args.color[4:6], base=16))
 else:
-    # TODO random color
-    color = tuple(int(c * 255) for c in colorsys.hsv_to_rgb(random.random(), 0.5, 0.9))
-    print(f"Generated random color: {color}")
+    color = tuple(int(c * 255) for c in colorsys.hsv_to_rgb(random.random(), 0.9, 0.9))
+    print(f"Generated random color: #{''.join(hex(c)[2:] for c in color)} / {color}")
 
 results = []
 with open(args.database) as infile: