def draw_directed_edge(self, edge, src_vertex, dest_vertex): if src_vertex == dest_vertex: # TODO return self.draw_loop_edge(edge, src_vertex) src_pos, dest_pos = src_vertex.position, dest_vertex.position ctx = self.context # Set up the gradient lg = LinearGradient(src_pos[0], src_pos[1], dest_pos[0], dest_pos[1]) edge_color = edge.color[:3] + self.alpha_at_src edge_color_end = edge_color[:3] + self.alpha_at_dest lg.add_color_stop_rgba(0, *edge_color) lg.add_color_stop_rgba(1, *edge_color_end) # Draw the edge ctx.set_source(lg) ctx.set_line_width(edge.width) ctx.move_to(*src_pos) ctx.line_to(*dest_pos) ctx.stroke()