Exemplo n.º 1
0
	def pushLine(self, color, geometry):
		isg = InstructionGroup()
		converted_coordinates = []
		for x, y in geometry:
			converted_coordinates.extend(
				self.relativeCoordinatesToScreenCoordinates(x, y)
			)

		# The stencil operations referenced here ensure that the contours do not
		# draw outside the image. Without these, the contours would be all over the 
		# place when zooming in (unless manual clipping was implemented).
		isg.add(StencilPush())
		isg.add(Rectangle(
			pos=(self.display_x, self.display_y),
			size=(self.display_width, self.display_height)
		))
		isg.add(StencilUse())		
		isg.add(Color(*color))
		isg.add(Line(
			points=converted_coordinates,
			width=1.0
		))
		isg.add(StencilUnUse())
		isg.add(Rectangle(
			pos=(self.display_x, self.display_y),
			size=(self.display_width, self.display_height)
		))
		isg.add(StencilPop())

		self.lines.append(geometry)
		self.colors.append(color)
		self.instruction_groups.append(isg)
		self.canvas.add(isg)
Exemplo n.º 2
0
 def lay_canvas_instructions(self):
     with self.canvas.after:
         StencilPush()
         RoundedRectangle(size=self.size, pos=self.pos, radius=[self._radius])
         StencilUse()
         self.col_instruction = Color(rgba=self.ripple_color)
         self.ellipse = Ellipse(
             size=(self.ripple_rad, self.ripple_rad),
             pos=(
                 self.ripple_pos[0] - self.ripple_rad / 2.0,
                 self.ripple_pos[1] - self.ripple_rad / 2.0,
             ),
         )
         StencilUnUse()
         RoundedRectangle(size=self.size, pos=self.pos, radius=[self._radius])
         StencilPop()
     self.bind(ripple_color=self._set_color, ripple_rad=self._set_ellipse)
Exemplo n.º 3
0
	def updateContoursForZoom(self):
		# We need to update all of the rectangles in the canvas that pertain
		# to drawing contours.

		# Get rid of the existing graphics objects.
		for g in range(len(self.instruction_groups)):
			self.canvas.remove(self.instruction_groups[-1])
			self.instruction_groups.remove(self.instruction_groups[-1])

		# Add new graphics instructions with appropriate coordinates.
		
		# Redraw them normally.
		for geo, color in zip(self.lines, self.colors):
			isg = InstructionGroup()
			converted_coordinates = []
			for x, y in geo:
				converted_coordinates.extend([
					self.relativeCoordinatesToScreenCoordinates(x, y)
				])

			# The stencil operations referenced here ensure that the contours 
			# do not draw outside the image. Without these, the contours would 
			# be all over the place when zooming in (unless manual clipping was
			# implemented).
			isg.add(StencilPush())
			isg.add(Rectangle(
				pos=(self.display_x, self.display_y),
				size=(self.display_width, self.display_height)
			))
			isg.add(StencilUse())		
			isg.add(Color(*color))
			isg.add(Line(
				points=converted_coordinates,
				width=1.0
			))
			isg.add(StencilUnUse())
			isg.add(Rectangle(
				pos=(self.display_x, self.display_y),
				size=(self.display_width, self.display_height)
			))
			isg.add(StencilPop())
			self.instruction_groups.append(isg)
			self.canvas.add(isg)
Exemplo n.º 4
0
    def __init__(self, **kwargs):
        self.canvas = Canvas()

        window_width = Window.width
        window_height = Window.height

        aspect = window_width / float(window_height)

        center_x = window_width / 2.
        center_y = window_height / 2.

        element_size = window_width

        with self.canvas:
            self.fbo = Fbo(size=self.size, with_depthbuffer=True)
            self.fbo_color = Color(1, 1, 1, 1)
            self.fbo_rects = (
                StencilPush(),
                Triangle(points=(
                    0,
                    0,
                    center_x * 1.5,
                    window_height,
                    0,
                    window_height,
                )),
                StencilUse(),
                Rotate(angle=-90,
                       axis=(0, 0, 1),
                       origin=(center_x, window_height * 2 / 3.)),
                Rectangle(pos=(center_x - element_size / 2., -5),
                          size=(element_size, element_size / aspect),
                          texture=self.texture),
                Rotate(angle=90,
                       axis=(0, 0, 1),
                       origin=(center_x, window_height * 2 / 3.)),
                StencilUnUse(),
                Triangle(points=(
                    0,
                    0,
                    center_x * 1.5,
                    window_height,
                    0,
                    window_height,
                )),
                StencilPop(),
                StencilPush(),
                Triangle(points=(
                    window_width,
                    0,
                    center_x * .5,
                    window_height,
                    window_width,
                    window_height,
                )),
                StencilUse(),
                Rotate(angle=90,
                       axis=(0, 0, 1),
                       origin=(center_x, window_height * 2 / 3.)),
                Rectangle(pos=(center_x - element_size / 2., -5),
                          size=(element_size, element_size / aspect),
                          texture=self.texture),
            )

            Rotate(angle=-90,
                   axis=(0, 0, 1),
                   origin=(center_x, window_height * 2 / 3.))

            StencilUnUse()
            Triangle(points=(
                window_width,
                0,
                center_x * .5,
                window_height,
                window_width,
                window_height,
            ))
            StencilPop()

            StencilPush()
            Triangle(points=(
                0,
                0,
                window_width,
                0,
                center_x,
                window_height * 2 / 3.,
            ))
            StencilUse()

            if self.texture:
                self.texture.flip_horizontal()
            self.mirrored_rect = Rectangle(pos=(center_x - element_size / 2.,
                                                0),
                                           size=(element_size,
                                                 element_size / aspect),
                                           texture=self.texture)

            StencilUnUse()
            Triangle(points=(
                0,
                0,
                window_width,
                0,
                center_x,
                window_height * 2 / 3.,
            ))
            StencilPop()

        with self.fbo:
            ClearColor(0, 0, 0, 0)
            ClearBuffers()

        self.texture = self.fbo.texture
        super(HoloStandLayout, self).__init__(**kwargs)