ted-editor.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:ted-editor 作者: tarnheld 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号