def draw_graph(self): b = cocos.batch.BatchableNode() for node in self.nodes: players = self.nodes[node].keys() for edge in self.nodes[node][players[0]]: if edge[1] > node[1]: color = rgba('yellow', 125) elif edge[1] < node[1]: color = rgba('green', 125) else: color = rgba('red', 125) l = draw.Line( (node[0], node[1]), (edge[0], edge[1]), color, stroke_width=3) b.add(l) self.manager.layer.add(b, z=4)
from util import mix, in_module, rgba from OpenGL.GL import * from vertexformat import VertexFormat from vertexstream import VertexStream from texturecache import TextureCache from patch9 import Patch9 from image import Image from program import Program image_empty = Image(1, 1, "\xff\xff\xff\xff") white = rgba(255, 255, 255, 255) fmt = VertexFormat([ ('position', 2, GL_FALSE, GL_FLOAT), ('texcoord', 2, GL_FALSE, GL_FLOAT), ('color', 4, GL_TRUE, GL_UNSIGNED_BYTE), ]) def quad_gradient(stream, (left, top, width, height), (s0,t0,s1,t1), (tl,tr,bl,br)): stream.vertex((left, top), (s0, t0), tuple(tl)) stream.vertex((left, top+height), (s0, t1), tuple(bl)) stream.vertex((left+width, top), (s1, t0), tuple(tr)) stream.vertex((left+width, top), (s1, t0), tuple(tr)) stream.vertex((left, top+height), (s0, t1), tuple(bl)) stream.vertex((left+width, top+height), (s1, t1), tuple(br)) def quad_flat(stream, (left, top, width, height), (s0,t0,s1,t1), color): color = tuple(color) stream.vertex((left, top), (s0, t0), color) stream.vertex((left, top+height), (s0, t1), color) stream.vertex((left+width, top), (s1, t0), color)