def drawContours(self, path):
# print("load contours",path)
try:
self.canvas.delete("contour")
except tk.TclError:
pass
import re
self.contours = np.load(path)
ex = self.scene["ex"]
lf = len(self.contours.files)
for a in self.contours.files:
cs = self.contours[a]
h = int(re.findall('\d+', a)[0])
h /= lf
# print("file",a,h)
# print("contours",len(cs))
col = colorsys.rgb_to_hsv(0.7, 0.9, 0.85)
hue = col[0] - h / 2
hue = m.fmod(hue, 1)
col = (hue, max(0, min(col[1], 1)), max(0, min(col[2], 1)))
col = colorsys.hsv_to_rgb(*col)
hexcol = rgb2hex(col)
for c in cs:
if len(c):
cc = [((x[1] - 512) / 1024 * ex * 2, (x[0] - 512) / 1024 * ex * 2) for x in c]
if la.norm(c[-1] - c[0]) < 0.01:
self.canvas.create_polygon(cc, fill="", outline=hexcol, width=7, tag="contour")
else:
self.canvas.create_line(cc, fill=hexcol, width=7, tag="contour")
try:
self.canvas.tag_lower("contour")
except tk.TclError:
pass
sys.stdout.flush()
评论列表
文章目录