def draw_in(self, aMapViewer):
        '''implement the method to draw in the MapViewer
		'''
        radius = 150.0 / aMapViewer.scale
        x = aMapViewer.cmin[0]
        y = aMapViewer.cmin[1]
        (display_width, display_height) = aMapViewer.parent.size

        for aPoi in self.pois:
            (poi_x, poi_y) = aMapViewer.get_local_xy_from_latlon(
                float(aPoi.poinulat), float(aPoi.poinulon), display_width,
                display_height)
            img_poi = Rectangle(pos=(x + poi_x / aMapViewer.scale - radius / 2,
                                     y + poi_y / aMapViewer.scale))
            img_poi.source = 'images/location_%s.png' % self.categories[
                aPoi.poiidcat].catcdcode
            img_poi.size = (radius, radius)
            aMapViewer.canvas.add(img_poi)

        # draw the current position
        (curr_x, curr_y) = aMapViewer.get_local_xy_from_latlon(
            self.current_position[0], self.current_position[1], display_width,
            display_height)
        img_position = Rectangle(
            pos=(x + curr_x / aMapViewer.scale - radius / 2,
                 y + curr_y / aMapViewer.scale - radius / 2))
        img_position.source = 'images/my-position.png'
        img_position.size = (radius, radius)
        aMapViewer.canvas.add(img_position)

        return
示例#2
0
    def update(self, dt):
        # if self.should_stop_rec:
        #     self.stop_recording()
        #     self.should_stop_rec = False

        self.transcriber.call_callbacks()
        self.is_transcribing = self.transcriber.is_transcribing()

        self.color_elem.rgba = self.color
        center_pos = (self.pos[0] + self.size[0] / 2,
                      self.pos[1] + self.size[1] / 2)
        origin_pos = (center_pos[0] - self.num_bars / 2 * self.bar_width,
                      center_pos[1])
        for i in range(self.num_bars):
            if len(self.bars) <= i:
                bar = Rectangle()
                self.canvas.add(bar)
                self.bars.append(bar)
            else:
                bar = self.bars[i]
            height = self.amplitudes[i] * np.sin(
                2 * np.pi * self.frequencies[i] * self.current_time) * 40.0
            if height >= 0:
                bar.pos = (origin_pos[0] + i * self.bar_width, origin_pos[1])
            else:
                bar.pos = (origin_pos[0] + i * self.bar_width,
                           origin_pos[1] + height)
            bar.size = (self.bar_width, np.abs(height))

        if self.is_recording and not self.is_paused:
            self.current_time += dt
示例#3
0
文件: transform.py 项目: 2xR/legacy
    def __get_dbg_origin_gfx(self):
        if self.__dbg_origin is None:
            c1 = Color(1, 0, 0, 0.5)
            r1 = Rectangle()
            c2 = Color(0, 1, 0, 0.5)
            r2 = Rectangle()
            c3 = Color(0, 0, 1, 0.5)
            e = Ellipse()
            group = InstructionGroup()
            for instruction in (c1, r1, c2, r2, c3, e):
                group.add(instruction)

            def update_geom(_, (w, h)):
                r1.size = (w, 0.1 * h)
                r2.size = (0.1 * w, h)
                e.size = (0.5 * w, 0.5 * h)
                e.pos = (0.25 * w, 0.25 * h)

            self.bind(viewport_size=update_geom)
            update_geom(None, self.size)
            self.__dbg_origin = group
示例#4
0
    def __init__(self, **kwargs):
        super(Floor, self).__init__(**kwargs)
        self.size_hint = None, None
        self._is_collidable = True
        self.root = App.get_running_app().root

        self.width = self.root.width
        self.height = 30

        with self.canvas:
            Color(0, 1., 0.01)
            GroundRec = Rectangle()
            GroundRec.pos = (0, 0)
            GroundRec.size = [self.width, self.height]
示例#5
0
文件: transform.py 项目: 2xR/legacy
    def __get_dbg_aabb_gfx(self):
        if self.__dbg_aabb is None:
            c = Color(0.8, 0.8, 0.8, 0.3)
            r = Rectangle()
            group = InstructionGroup()
            for instruction in (c, r):
                group.add(instruction)

            def update_r(_, ((left, bottom), (right, top))):
                r.pos = (left, bottom)
                r.size = (right - left, top - bottom)

            self.bind(aabb=update_r)
            update_r(None, self.aabb)
            self.__dbg_aabb = group
	def draw_in(self, aMapViewer):
		'''implement the method to draw in the MapViewer
		'''
		radius = 150.0/aMapViewer.scale
		x = aMapViewer.cmin[0]
		y = aMapViewer.cmin[1]
		(display_width, display_height) = aMapViewer.parent.size
		
		for aPoi in self.pois:
			(poi_x,poi_y) = aMapViewer.get_local_xy_from_latlon(float(aPoi.poinulat), float(aPoi.poinulon), display_width, display_height)
			#with aMapViewer.canvas:
			#	Color(1, 0, 0, 0.8)
			#	Ellipse(pos=(x + poi_x/aMapViewer.scale - radius/2, y + poi_y/aMapViewer.scale - radius/2), size=(radius,radius))
			img_poi = Rectangle( pos=(x + poi_x/aMapViewer.scale - radius/2, y + poi_y/aMapViewer.scale ) )
			img_poi.source='images/location_%s.png' % self.categories[aPoi.poiidcat].catcdcode
			img_poi.size = (radius,radius)
			aMapViewer.canvas.add(img_poi)
		
		# draw the current position
		(curr_x, curr_y) = aMapViewer.get_local_xy_from_latlon(self.current_position[0], self.current_position[1], display_width, display_height)
		aMapViewer.canvas.add(Color(0, 1, 1, 0.8))
		aMapViewer.canvas.add(Ellipse(pos=(x + curr_x/aMapViewer.scale - radius/2, y + curr_y/aMapViewer.scale - radius/2), size=(radius/4,radius/4)) )
		
		return