def do_draw_face(self): N = 48 vertices = [] for i in range(N + 2): direction = Vector.from_degrees(360 * i / N) radius = self._radius - (i % 2 * self.custom_face_border_width) vertex = self.rect.center + radius * direction vertices += vertex.tuple # Insert duplicate vertices at the beginning and end of the list, # otherwise this triangle strip will end up connected to any other # triangle strips in the scene. vertices = vertices[:2] + vertices + vertices[-2:] num_vertices = len(vertices) // 2 color = glooey.drawing.Color.from_anything(self._color) colors = num_vertices * color.rgb # The vertex list for the face may or may not exist yet, e.g. if the # clock is being drawn for the first time or was previously being # hidden. So create the vertex list if we need to, otherwise just # update its coordinates. if self._face is None: self._face = self.batch.add( num_vertices, GL_TRIANGLE_STRIP, self.group, ('v2f', vertices), ('c3B', colors), ) else: self._face.vertices = vertices self._face.colors = colors
def _yield_offsets(self): N = len(self._children) for i, child in enumerate(self._children): offset = self.radius * Vector.from_degrees(360 * i / N) yield child, offset