Esempio n. 1
0
 def render(self):
     w, h =  2*(2*(self.bounds_radius + self.image_margin),)
     tx, ty = 2*(self.bounds_radius + self.image_margin,)
     with dye.Image(w, h) as img:            
         with dye.translation(tx, ty):
             self.draw_network()
     return img
Esempio n. 2
0
def render_tree(root_node, gradient):    
    with dye.translation(-root_node.bounds.x, -root_node.bounds.y):
        for node in walk(root_node):
            if node.parent is not None:
                x0, y0, x1, y1 = (node.parent.x, node.parent.y, node.x, node.y)
                seg_gradient = dye.Gradient(start = gradient.get_interpolated_color(node.parent.weight),
                                            stop = gradient.get_interpolated_color(node.weight))
                seg = dye.BezierPath()
                seg.move_to(x0, y0)
                seg.line_to(x1, y1)
                with dye.ContextFrame():
                    seg.clip_to_outline()
                    seg_gradient.draw_linear_in_rect(seg.bounds(), math.atan2(x1 - x0, y1 - y0))