def do_paint(self): cogl.push_matrix() for child in self._children: if child.props.mapped: child.paint() cogl.pop_matrix()
def __paint_triangle (self, color): cogl.push_matrix() cogl.set_source_color(color) width, height = self.get_geometry()[2:] # Paint a triangle cogl.path_polygon(0, 0, 0, height, width, height) cogl.path_fill() cogl.pop_matrix()
def __paint_triangle(self, color): cogl.push_matrix() cogl.set_source_color(color) width, height = self.get_geometry()[2:] # Paint a triangle cogl.path_polygon(0, 0, 0, height, width, height) cogl.path_fill() cogl.pop_matrix()
def do_paint(self): parent = self.get_source() if parent is None: return # get the cogl handle for the parent texture cogl_tex = parent.get_cogl_texture() if not cogl_tex: return (width, height) = self.get_size() # clamp the reflection height if needed r_height = self._reflection_height if r_height < 0 or r_height > height: r_height = height rty = float(r_height / height) opacity = self.get_paint_opacity() # the vertices are a 6-tuple composed of: # x, y, z: coordinates inside Clutter modelview # tx, ty: texture coordinates # color: a clutter.Color for the vertex # # to paint the reflection of the parent texture we paint # the texture using four vertices in clockwise order, with # the upper left and the upper right at full opacity and # the lower right and lower left and 0 opacity; OpenGL will # do the gradient for us color1 = cogl.color_premultiply((1, 1, 1, opacity / 255.0)) color2 = cogl.color_premultiply((1, 1, 1, 0)) vertices = ( (0, 0, 0, 0.0, 1.0, color1), (width, 0, 0, 1.0, 1.0, color1), (width, r_height, 0, 1.0, 1.0 - rty, color2), (0, r_height, 0, 0.0, 1.0 - rty, color2), ) cogl.push_matrix() cogl.set_source_texture(cogl_tex) cogl.polygon(vertices=vertices, use_color=True) cogl.pop_matrix()
def do_paint(self): parent = self.get_source() if (parent is None): return # get the cogl handle for the parent texture cogl_tex = parent.get_cogl_texture() if not cogl_tex: return (width, height) = self.get_size() # clamp the reflection height if needed r_height = self._reflection_height if (r_height < 0 or r_height > height): r_height = height rty = float(r_height / height) opacity = self.get_paint_opacity() # the vertices are a 6-tuple composed of: # x, y, z: coordinates inside Clutter modelview # tx, ty: texture coordinates # color: a clutter.Color for the vertex # # to paint the reflection of the parent texture we paint # the texture using four vertices in clockwise order, with # the upper left and the upper right at full opacity and # the lower right and lower left and 0 opacity; OpenGL will # do the gradient for us color1 = cogl.color_premultiply((1, 1, 1, opacity / 255.)) color2 = cogl.color_premultiply((1, 1, 1, 0)) vertices = ( \ ( 0, 0, 0, 0.0, 1.0, color1), \ (width, 0, 0, 1.0, 1.0, color1), \ (width, r_height, 0, 1.0, 1.0-rty, color2), \ ( 0, r_height, 0, 0.0, 1.0-rty, color2), \ ) cogl.push_matrix() cogl.set_source_texture(cogl_tex) cogl.polygon(vertices=vertices, use_color=True) cogl.pop_matrix()