__init__.py 文件源码

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

项目:HTM_experiments 作者: ctrl-z-9000-times 项目源码 文件源码
def add_label_outline(self, label, outline):
        """
        Save the given label to file.

        Argument label can be a color or a string
        Argument outline is list of pairs of (x, y) coordinates of a polygon
                 If the length of outline is less than 2, this does nothing.
        """
        if isinstance(label, str):
            label = next(c for c, nm in self.names.items() if nm == label)
        assert(isinstance(label, tuple) and len(label) == 4) # Colors are tuples of 4 ints
        if len(outline) < 2:
            return # Already done.
        im = Image.open(self.current_label)
        # Draw the polygon
        draw = ImageDraw.Draw(im)
        draw.polygon(outline, fill=label)
        del draw
        im.save(self.current_label)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号