def on_entry_paint(actor):
    allocation = actor.get_allocation_box()

    allocation.clamp_to_pixel()

    Cogl.set_source_color4ub(255, 255, 255, 50)
    Cogl.rectangle(0, 0, *allocation.get_size())
def on_entry_paint(actor):
    allocation = actor.get_allocation_box()

    allocation.clamp_to_pixel()

    Cogl.set_source_color4ub(255, 255, 255, 50);
    Cogl.rectangle(0, 0, *allocation.get_size());
예제 #3
0
    def do_pick(self, pick_color):
        if not self.should_pick_paint():
            return

        Cogl.Path.new()

        Cogl.set_source_color4ub(pick_color.red, pick_color.green,
                                 pick_color.blue, pick_color.alpha)
        self.draw_path()
        Cogl.Path.fill()
    def do_pick(self, pick_color):
        if not self.should_pick_paint():
            return

        Cogl.Path.new()

        Cogl.set_source_color4ub(pick_color.red, pick_color.green, pick_color.blue, pick_color.alpha)
 
        self._path.foreach(self.convert_clutter_path_node, None)

        Cogl.Path.fill()
예제 #5
0
    def do_paint(self):
        ok, color = Clutter.Color.from_string(self._color)

        tmp_alpha = self.get_paint_opacity() * color.alpha / 255

        Cogl.Path.new()
        Cogl.set_source_color4ub(color.red, color.green, color.blue, tmp_alpha)
        self.draw_path()
        Cogl.Path.fill_preserve()
        Cogl.set_source_color4ub(color.red, color.green, color.blue, 255)
        Cogl.Path.stroke()
    def do_paint(self):
        w, h = self.get_allocation_box().get_size()

        Cogl.scale(w, h, 1.0)
        Cogl.Path.new()
        Cogl.Path.move_to(0.0, 1.0)
        Cogl.Path.line_to(0.5, 0.0)
        Cogl.Path.line_to(1.0, 1.0)
        Cogl.Path.curve_to(1.0, 0.75, 0.0, 0.75, 0.0, 1.0)
        Cogl.set_source_color4ub(100, 150, 200, 255)
        Cogl.Path.fill()
    def do_pick(self, pick_color):
        if not self.should_pick_paint():
            return

        Cogl.Path.new()

        Cogl.set_source_color4ub(pick_color.red, pick_color.green,
                                 pick_color.blue, pick_color.alpha)

        self._path.foreach(self.convert_clutter_path_node, None)

        Cogl.Path.fill()
    def do_paint(self):
        color = self._color

        tmp_alpha = self.get_paint_opacity() * color.alpha / 255

        Cogl.Path.new()

        Cogl.set_source_color4ub(color.red, color.green, color.blue, tmp_alpha)

        self._path.foreach(self.convert_clutter_path_node, None)

        Cogl.Path.fill()
    def do_paint(self):
        color = self._color

        tmp_alpha = self.get_paint_opacity() * color.alpha / 255

        Cogl.Path.new()

        Cogl.set_source_color4ub(color.red, color.green, color.blue, tmp_alpha)

        self._path.foreach(self.convert_clutter_path_node, None)

        Cogl.Path.fill()
예제 #10
0
    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()
예제 #11
0
파일: elements.py 프로젝트: jojva/pitivi
 def _createBackground(self, track):
     self.background = RoundedRectangle(0, 0, 0, 0)
     color = Cogl.Color()
     color.init_from_4ub(35, 85, 125, 125)  # light blue
     self.background.set_color(color)
     self.background.set_border_width(1)
     self.background.set_position(0, 0)
     self.add_child(self.background)
예제 #12
0
파일: main.py 프로젝트: RainCT/tortellini
    def do_pick(self, color):
        if not self.should_pick_paint():
            return

        allocation = self.get_allocation_box()
        (width, height) = allocation.get_size()

        Cogl.clip_push_rectangle(0, 0, width, height)

        cogl_color = Cogl.Color()
        cogl_color.init_from_4ub(color.red, color.green, color.blue, color.alpha)
        Cogl.set_source_color(cogl_color)
        Cogl.path_rectangle(0, 0, width, height)
        Cogl.path_fill()

        Cogl.clip_pop()
        
        for child in self.get_children():
            child.paint()
    def do_pick(self, pick_color):
        if not self.should_pick_paint():
            return

        allocation = self.get_allocation_box()
        width, height = allocation.get_size()

        Cogl.Path.new()
        Cogl.set_source_color4ub(pick_color.red, pick_color.green, pick_color.blue, pick_color.alpha)

        Cogl.Path.move_to(width * 0.5, 0)
        Cogl.Path.line_to(width, height * 0.75)
        Cogl.Path.line_to(0, height * 0.75)
        Cogl.Path.move_to(width * 0.5, height)
        Cogl.Path.line_to(0, height * 0.25)
        Cogl.Path.line_to(width, height * 0.25)
        Cogl.Path.line_to(width * 0.5, height)

        Cogl.Path.fill()
    def do_pick(self, pick_color):
        if not self.should_pick_paint():
            return

        allocation = self.get_allocation_box()
        width, height = allocation.get_size()

        Cogl.Path.new()
        Cogl.set_source_color4ub(pick_color.red, pick_color.green,
                                 pick_color.blue, pick_color.alpha)

        Cogl.Path.move_to(width * 0.5, 0)
        Cogl.Path.line_to(width, height * 0.75)
        Cogl.Path.line_to(0, height * 0.75)
        Cogl.Path.move_to(width * 0.5, height)
        Cogl.Path.line_to(0, height * 0.25)
        Cogl.Path.line_to(width, height * 0.25)
        Cogl.Path.line_to(width * 0.5, height)

        Cogl.Path.fill()
    def do_paint(self):
        allocation = self.get_allocation_box()
        width, height = allocation.get_size()

        color = self._color

        tmp_alpha = self.get_paint_opacity() * color.alpha / 255

        Cogl.Path.new()
        Cogl.set_source_color4ub(color.red, color.green, color.blue, tmp_alpha)

        Cogl.Path.move_to(width * 0.5, 0)
        Cogl.Path.line_to(width, height * 0.75)
        Cogl.Path.line_to(0, height * 0.75)
        Cogl.Path.move_to(width * 0.5, height)
        Cogl.Path.line_to(0, height * 0.25)
        Cogl.Path.line_to(width, height * 0.25)
        Cogl.Path.line_to(width * 0.5, height)

        Cogl.Path.fill()
    def do_paint(self):
        allocation = self.get_allocation_box()
        width, height = allocation.get_size()

        color = self._color

        tmp_alpha = self.get_paint_opacity() * color.alpha / 255

        Cogl.Path.new()
        Cogl.set_source_color4ub(color.red, color.green, color.blue, tmp_alpha)

        Cogl.Path.move_to(width * 0.5, 0)
        Cogl.Path.line_to(width, height * 0.75)
        Cogl.Path.line_to(0, height * 0.75)
        Cogl.Path.move_to(width * 0.5, height)
        Cogl.Path.line_to(0, height * 0.25)
        Cogl.Path.line_to(width, height * 0.25)
        Cogl.Path.line_to(width * 0.5, height)

        Cogl.Path.fill()
예제 #17
0
파일: elements.py 프로젝트: jojva/pitivi
    def _createBorder(self):
        self.border = RoundedRectangle(0, 0, 0, 0)
        self.border.bElement = self.bElement
        color = Cogl.Color()

        color.init_from_4ub(100, 100, 100, 255)
        self.border.set_border_color(color)
        self.border.set_border_width(1)
        self.border.set_position(0, 0)

        self.add_child(self.border)
예제 #18
0
    def __init__(self, config):
        super(VolumeStage, self).__init__()
        self.config = config
        self.ui = config.ui
        self.p = self.ui.get_object("volume-wrapper")

        # Set up touch events linked to the viewport
        self.vp = self.ui.get_object("volume-viewport")
        self.vp.set_reactive(True)
        self.vp.connect("scroll-event", self.scroll)
        self.rotation = int(config.screen_rot)

        self.angle_max = config.getfloat("System", "angle_max")
        self.angle_min = config.getfloat("System", "angle_min")
        self.scale_max = config.getfloat("System", "scale_max")
        self.scale_min = config.getfloat("System", "scale_min")

        self.spinner = self.ui.get_object("spinner")
        self.clicked = False
        self.scale = 1.2

        if hasattr(Clutter, 'Matrix'):
            m = Clutter.Matrix.alloc()
            m.init_from_array(
                [-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1])
        else:
            cm = Cogl.Matrix()
            m = Clutter.matrix_init_from_array(
                cm, [-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1])

        self.ui.get_object("content-flip").set_transform(m)

        zoom = Clutter.ZoomAction()
        self.vp.add_action(zoom)
        zoom.connect("zoom", self.zoom)
        zoom.connect("gesture-begin", self.zoom_begin)
        zoom.connect("gesture-end", self.zoom_end)

        pan = Clutter.PanAction()
        self.vp.add_action(pan)
        pan.connect("pan", self.pan)
        pan.connect("gesture-begin", self.pan_begin)
        pan.connect("gesture-end", self.pan_end)
        pan.connect("gesture-cancel", self.pan_cancel)

        #self.config.stage.connect("motion-event", self.motion)

        self.zoom_start = self.scale
        self.zooming = False
        self.last_x = 0
        self.last_y = 0

        self.panning = False
예제 #19
0
    def __init__(self, config):
        super(Model, self).__init__()

        self.config = config
        self.model = config.ui.get_object("model")
        color_str = config.get("System", "model-color")
        self.color = Clutter.Color.from_string(color_str)[1]
        self.loader = config.ui.get_object("loader")
        self.loader.set_from_file(config.get("System", "loader"))

        self.model_data = Mash.Data()
        self.model.set_data(self.model_data)
        self.v_min = Clutter.Vertex()
        self.v_max = Clutter.Vertex()
        self.depth = 0

        self.t = Clutter.PropertyTransition(property_name='rotation-angle-z')
        self.t.set_from(0)
        self.t.set_to(360)
        self.t.set_duration(3000)
        self.t.set_animatable(self.loader)
        self.t.set_repeat_count(-1)
        self.t.start()

        #Set up the light
        self.light_set = Mash.LightSet()
        vp = config.ui.get_object("volume-viewport")

        # Directional
        self.light_directional = Mash.DirectionalLight()
        self.light_set.add_light(self.light_directional)

        # Point light
        self.light_point = Mash.PointLight()
        self.light_set.add_light(self.light_point)
        
        # Add the model the lights to the volume viewport
        vp.add_child(self.light_directional);
        vp.add_child(self.light_point);

        cm = Cogl.Matrix()
        m = Clutter.matrix_init_from_array(cm, [
             1, 0, 0, 0,
             0, -1, 0, 0,
             0, 0, 1, 0,
             0, 0, 0, 1])
        config.ui.get_object("model-flipper").set_transform(m)

        self.model.connect("show", self.model_loaded)

        self.model.set_light_set(self.light_set)
        self.model.set_color(self.color)
예제 #20
0
 def __draw_shape(self, width, height, color=None, texture=None):
     if texture:
         Cogl.set_source_texture(texture)
     else:
         tmp_alpha = self.get_paint_opacity() * color.alpha / 255
         Cogl.set_source_color4ub(color.red, color.green, color.blue, tmp_alpha)
     self.do_draw_shape(width, height)
     Cogl.path_fill()
예제 #21
0
    def do_paint(self):
        x = numpy.arange(-400, 400)
        y = 20 * numpy.sin(x * 0.1)

        # Plot trace, setting down lines wherever both x and y are finite
        # (neither NaN, nor infinity, nor minus infinity)
        pendown = False
        for x, y in zip(x, y):
            if numpy.isfinite(x) and numpy.isfinite(y):
                # x -= self.get_x()
                # y -= self.get_y()
                if pendown:
                    Cogl.path_line_to(x, -y)
                else:
                    Cogl.path_move_to(x, -y)
                    pendown = True
            else:
                pendown = False
        Cogl.set_source_color(cogl_color_from_clutter_color(self.color))
        Cogl.path_stroke()
예제 #22
0
	def do_paint(self):
		x = numpy.arange(-400, 400)
		y = 20 * numpy.sin(x * 0.1)

		# Plot trace, setting down lines wherever both x and y are finite
		# (neither NaN, nor infinity, nor minus infinity)
		pendown = False
		for x, y in zip(x, y):
			if numpy.isfinite(x) and numpy.isfinite(y):
				#x -= self.get_x()
				#y -= self.get_y()
				if pendown:
					Cogl.path_line_to(x, -y)
				else:
					Cogl.path_move_to(x, -y)
					pendown = True
			else:
				pendown = False
		Cogl.set_source_color(cogl_color_from_clutter_color(self.color))
		Cogl.path_stroke()
예제 #23
0
	def paint(self):
		"""paint signal handler."""
		w, h = self.get_size()
		half_w = 0.5 * w
		half_h = 0.5 * h
		half_major = self.MAJOR_PIXELS / 2
		tenth_major = self.MAJOR_PIXELS / 10

		# Fill background.
		Cogl.set_source_color(cogl_color_from_clutter_color(self.BACKGROUND_COLOR))
		Cogl.rectangle(-half_w, -half_h, half_w, half_h)

		# Create paths for vertical gridlines.
		x0 = int((-half_w // self.MAJOR_PIXELS) * self.MAJOR_PIXELS)
		for x in xrange(x0, int(math.ceil(half_w)), self.MAJOR_PIXELS):
			halfway = x + half_major
			vline(x, -half_h, half_h)
			vline(halfway, -8, 0)
			for xx in xrange(x + tenth_major, halfway, tenth_major):
				vline(xx, -4, 0)
			for xx in xrange(halfway + tenth_major, x + self.MAJOR_PIXELS, tenth_major):
				vline(xx, -4, 0)

		# Create paths for horizontal gridlines.
		y0 = int((-half_h // self.MAJOR_PIXELS) * self.MAJOR_PIXELS)
		for y in xrange(y0, int(math.ceil(half_h)), self.MAJOR_PIXELS):
			halfway = y + half_major
			hline(y, -half_w, half_w)
			hline(halfway, 0, 8)
			for yy in xrange(y + tenth_major, halfway, tenth_major):
				hline(yy, 0, 4)
			for yy in xrange(halfway + tenth_major, y + self.MAJOR_PIXELS, tenth_major):
				hline(yy, 0, 4)

		# Stroke gridlines.
		Cogl.set_source_color(cogl_color_from_clutter_color(self.GRIDLINE_COLOR))
		Cogl.path_stroke()
예제 #24
0
    def paint(self):
        """paint signal handler."""
        w, h = self.get_size()
        half_w = 0.5 * w
        half_h = 0.5 * h
        half_major = self.MAJOR_PIXELS / 2
        tenth_major = self.MAJOR_PIXELS / 10

        # Fill background.
        Cogl.set_source_color(cogl_color_from_clutter_color(self.BACKGROUND_COLOR))
        Cogl.rectangle(-half_w, -half_h, half_w, half_h)

        # Create paths for vertical gridlines.
        x0 = int((-half_w // self.MAJOR_PIXELS) * self.MAJOR_PIXELS)
        for x in xrange(x0, int(math.ceil(half_w)), self.MAJOR_PIXELS):
            halfway = x + half_major
            vline(x, -half_h, half_h)
            vline(halfway, -8, 0)
            for xx in xrange(x + tenth_major, halfway, tenth_major):
                vline(xx, -4, 0)
            for xx in xrange(halfway + tenth_major, x + self.MAJOR_PIXELS, tenth_major):
                vline(xx, -4, 0)

                # Create paths for horizontal gridlines.
        y0 = int((-half_h // self.MAJOR_PIXELS) * self.MAJOR_PIXELS)
        for y in xrange(y0, int(math.ceil(half_h)), self.MAJOR_PIXELS):
            halfway = y + half_major
            hline(y, -half_w, half_w)
            hline(halfway, 0, 8)
            for yy in xrange(y + tenth_major, halfway, tenth_major):
                hline(yy, 0, 4)
            for yy in xrange(halfway + tenth_major, y + self.MAJOR_PIXELS, tenth_major):
                hline(yy, 0, 4)

                # Stroke gridlines.
        Cogl.set_source_color(cogl_color_from_clutter_color(self.GRIDLINE_COLOR))
        Cogl.path_stroke()
예제 #25
0
    def do_draw_shadow(self, width, height):
        w = width / 5
        h = 35

        offset_x = 15
        offset_y = 15

        Cogl.path_move_to((width / 2) + (w / 3.) + offset_x, height - h + offset_y)
        Cogl.path_line_to(0 + offset_x, height - h + offset_y)
        Cogl.path_line_to(0 + offset_x, 0 + offset_y)
        Cogl.path_line_to(width + offset_x, 0 + offset_y)
        Cogl.path_line_to(width + offset_x, height - h + offset_y)
        Cogl.path_line_to((width / 2) + (w / 3. * 4) + offset_x, height - h + offset_y)
        Cogl.path_line_to(width / 2 + offset_x, height + offset_y)
        Cogl.path_line_to((width / 2) + (w / 3.) + offset_x, height - h + offset_y)
        Cogl.path_close()
예제 #26
0
def hline(y, x1, x2):
    """Draw a horizontal line from (x1, y) to (x2, y)."""
    Cogl.path_line(x1, y, x2, y)
예제 #27
0
	def paint(self):
		"""paint signal handler."""
		w, h = self.get_size()
		color = self.trace.color
		dark_color = color.darken()

		Cogl.set_source_color(cogl_color_from_clutter_color(dark_color))
		Cogl.path_round_rectangle(0, 0, w, h, 5, 10)
		Cogl.path_fill()

		Cogl.set_source_color(cogl_color_from_clutter_color(color))
		Cogl.path_round_rectangle(3, 3, w - 3, h - 3, 3, 10)
		Cogl.path_fill()
예제 #28
0
def cogl_color_from_clutter_color(c):
	"""Return a Cogl.Color that is equivalent to a Clutter.Color."""
	cogl_color = Cogl.Color()
	cogl_color.init_from_4ub(c.red, c.green, c.blue, c.alpha)
	return cogl_color
예제 #29
0
    def paint(self):
        """paint signal handler."""
        w, h = self.get_size()
        color = self.trace.color
        dark_color = color.darken()

        Cogl.set_source_color(cogl_color_from_clutter_color(dark_color))
        Cogl.path_round_rectangle(0, 0, w, h, 5, 10)
        Cogl.path_fill()

        Cogl.set_source_color(cogl_color_from_clutter_color(color))
        Cogl.path_round_rectangle(3, 3, w - 3, h - 3, 3, 10)
        Cogl.path_fill()
def canvas_paint_cb(self, path):
    Cogl.Path.new()
    Cogl.set_source_color4ub(255, 255, 0, 255)
    path.foreach(convert_clutter_path_node_to_cogl_path, None)
    Cogl.Path.stroke()
예제 #31
0
def hline(y, x1, x2):
	"""Draw a horizontal line from (x1, y) to (x2, y)."""
	Cogl.path_line(x1, y, x2, y)
예제 #32
0
 def __draw_outline(self, width, height, color=None):
     tmp_alpha = self.get_paint_opacity() * color.alpha / 255
     Cogl.set_source_color4ub(color.red, color.green, color.blue, tmp_alpha)
     self.do_draw_outline(width, height)
     Cogl.path_stroke()
 def do_paint(self):
     Cogl.Path.new()
     Cogl.set_source_color4ub(255, 255, 0, 255)
     self._path.foreach(self.convert_clutter_path_node_to_cogl_path, None)
     Cogl.Path.stroke()
 def do_paint(self):
     Cogl.Path.new()
     Cogl.set_source_color4ub(255, 255, 0, 255)
     self._path.foreach(self.convert_clutter_path_node_to_cogl_path, None)
     Cogl.Path.stroke()
예제 #35
0
 def __draw_shadow(self, width, height):
     Cogl.set_source_color4ub(0x0e, 0x0e, 0x0e, 0xbe)
     self.do_draw_shadow(width, height)
     Cogl.path_fill()
def canvas_paint_cb(self, path):
    Cogl.Path.new()
    Cogl.set_source_color4ub(255, 255, 0, 255)
    path.foreach(convert_clutter_path_node_to_cogl_path, None)
    Cogl.Path.stroke()
예제 #37
0
    def do_draw_outline(self, width, height):
        w = width / 5
        h = 35

        Cogl.path_move_to((width / 2) + (w / 3.), height - h)
        Cogl.path_line_to(0, height - h)
        Cogl.path_line_to(0, 0)
        Cogl.path_line_to(width, 0)
        Cogl.path_line_to(width, height - h)
        Cogl.path_line_to((width / 2) + (w / 3. * 4), height - h)
        Cogl.path_line_to(width / 2, height)
        Cogl.path_line_to((width / 2) + (w / 3.), height - h)
        Cogl.path_close()
예제 #38
0
def vline(x, y1, y2):
    """Draw a vertical line from (x, y1) to (x, y2)."""
    Cogl.path_line(x, y1, x, y2)
예제 #39
0
    def do_paint(self):

        # Draw a rectangle for the clipping
        Cogl.rectangle(0, 0, self._width, self._height)
        #Cogl.path_close()
        # Start the clip
        #Cogl.clip_push_from_path()

        # set color to border color
        Cogl.set_source_color(self._border_color)
        # draw the rectangle for the border which is the same size and the
        # object
        Cogl.path_round_rectangle(0, 0, self._width, self._height, self._arc,
                                  self._step)
        Cogl.path_close()
        # color the path usign the border color
        Cogl.path_fill()
        # set the color of the filled area
        Cogl.set_source_color(self._color)
        # draw the content with is the same size minus the wirth of the border
        # finish the clip
        Cogl.path_round_rectangle(self._border_width, self._border_width,
                                  self._width - self._border_width,
                                  self._height - self._border_width, self._arc,
                                  self._step)
        Cogl.path_fill()
        Cogl.path_close()

        Cogl.clip_pop()
예제 #40
0
파일: elements.py 프로젝트: jojva/pitivi
    def do_paint(self):
        # Set a rectangle for the clipping
        Cogl.clip_push_rectangle(0, 0, self.props.width, self.props.height)

        if self._border_color:
            # draw the rectangle for the border which is the same size as the
            # object
            Cogl.path_round_rectangle(0, 0, self.props.width,
                                      self.props.height, self._arc, self._step)
            Cogl.path_round_rectangle(self._border_width, self._border_width,
                                      self.props.width - self._border_width,
                                      self.props.height - self._border_width,
                                      self._arc, self._step)
            Cogl.path_set_fill_rule(Cogl.PathFillRule.EVEN_ODD)
            Cogl.path_close()

            # set color to border color
            Cogl.set_source_color(self._border_color)
            Cogl.path_fill()

        if self._color:
            # draw the content with is the same size minus the width of the border
            # finish the clip
            Cogl.path_round_rectangle(self._border_width, self._border_width,
                                      self.props.width - self._border_width,
                                      self.props.height - self._border_width,
                                      self._arc, self._step)
            Cogl.path_close()

            # set the color of the filled area
            Cogl.set_source_color(self._color)
            Cogl.path_fill()

        Cogl.clip_pop()
예제 #41
0
파일: main.py 프로젝트: RainCT/tortellini
    def do_paint(self):
        allocation = self.get_allocation_box()
        (width, height) = allocation.get_size()

        Cogl.clip_push_rectangle(0, 0, width, height)

        Cogl.set_source_color(self._border_color)
        Cogl.path_rectangle(0, 0, width, height)
        Cogl.path_close()
        Cogl.path_fill()

        Cogl.set_source_color(self._color)
        Cogl.path_rectangle(self._border, self._border,
                            width - self._border, height - self._border)
        Cogl.path_close()
        Cogl.path_fill()

        Cogl.clip_pop()

        Clutter.Actor.do_paint(self)
예제 #42
0
	def paint(self):
		if not is_dead:
			# TODO: Determine color and secondary color

			Cogl.set_source_color(color)

			path = Cogl.Path

			# Draw head arc
			path.move_to(0.0, 0.5)
			path.arc(0.5, 0.5, 0.5, 0.5, 180, 360)

			# Side line
			path.line_to(1.0, 1.0)

			# Zig-zag
			for i in range(3,0):
				path.line_to(i/4.0 + 1/8.0, 0.9)
				path.line_to(i/4.0, 1.0)

			# Other side
			path.close()
			path.fill()

		# Eyeball
		Cogl.set_source_color(sec_color)

		path = Cogl.Path
		
		# Left
		path.arc(1/4.0, 0.4, 1/6.0, 1/6.0, 0, 360)
		path.fill()

		# Right
		path.arc(1.0 - 1/4.0, 0.4, 1/6.0, 1/6.0, 0, 360)
		path.fill()

		if is_vunerable and not is_dead:
			path.move_to(0, 0.70)
			for i in range(1,3):
				path.line_to(i/3.0 - 1/6.0, 0.80)
				path.line_to(i/3.0, 0.70)
			path.stroke()
		else:
			# Pupil
			offset_x = offset_y = 0.0

			if self.direction == PPDirection.UP:
				offset_y -= 1/8.0
			elif self.direction == PPDirection.RIGHT:
				offset_x += 1/8.0
			elif self.direction == PPDirection.DOWN:
				offset_y += 1/8.0
			elif self.direction == PPDirection.LEFT:
				offset_x -= 1/8.0

			Cogl.set_source_color(PPColor.blue())

			path.arc(1/4.0 + offset_x, 0.4 + offset_y, 1/9.0, 1/9.0, 0, 360)
			path.fill()

			path.arc(1.0 - 1/4.0 + offset_x, 0.4 + offset_y, 1/9.0, 1/9.0, 0, 360)
			path.fill()
예제 #43
0
파일: elements.py 프로젝트: dark-al/pitivi
    def do_paint(self):
        # Set a rectangle for the clipping
        Cogl.clip_push_rectangle(0, 0, self.props.width, self.props.height)

        if self._border_color:
            # draw the rectangle for the border which is the same size as the
            # object
            Cogl.path_round_rectangle(0, 0, self.props.width, self.props.height,
                                      self._arc, self._step)
            Cogl.path_round_rectangle(self._border_width, self._border_width,
                                      self.props.width - self._border_width,
                                      self.props.height - self._border_width,
                                      self._arc, self._step)
            Cogl.path_set_fill_rule(Cogl.PathFillRule.EVEN_ODD)
            Cogl.path_close()

            # set color to border color
            Cogl.set_source_color(self._border_color)
            Cogl.path_fill()

        if self._color:
            # draw the content with is the same size minus the width of the border
            # finish the clip
            Cogl.path_round_rectangle(self._border_width, self._border_width,
                                      self.props.width - self._border_width,
                                      self.props.height - self._border_width,
                                      self._arc, self._step)
            Cogl.path_close()

            # set the color of the filled area
            Cogl.set_source_color(self._color)
            Cogl.path_fill()

        Cogl.clip_pop()
예제 #44
0
def vline(x, y1, y2):
	"""Draw a vertical line from (x, y1) to (x, y2)."""
	Cogl.path_line(x, y1, x, y2)
예제 #45
0
 def do_pick(self, color):
     if self.should_pick_paint() == False:
         return
     Cogl.path_round_rectangle(0, 0, self._width, self._height, self._arc,
                               self._step)
     Cogl.path_close()
     # Start the clip
     Cogl.clip_push_from_path()
     # set color to border color
     Cogl.set_source_color(color)
     # draw the rectangle for the border which is the same size and the
     # object
     Cogl.path_round_rectangle(0, 0, self._width, self._height, self._arc,
                               self._step)
     Cogl.path_close()
     Cogl.path_fill()
     Cogl.clip_pop()