Esempio n. 1
0
def drawLabel(text, pos=(0,0),center=True):
    _standard_label = Label(text='standard Label', font_size=200,bold=True, color=(255,255,255,75))
    _standard_label.anchor_x = 'left'
    _standard_label.anchor_y = 'bottom'
    _standard_label.x = 0
    _standard_label.y = 0
    _standard_label.text = text
    glPushMatrix()
    glTranslated(pos[0], pos[1], 0.0)
    glScaled(0.3,0.3,1)
    _standard_label.draw()
    glPopMatrix()
Esempio n. 2
0
def drawLabel(text, pos=(0, 0), center=True, textcolor=(255, 255, 255, 75)):
    _standard_label = Label(text="standard Label", font_size=200, bold=True, color=textcolor)
    _standard_label.anchor_x = "center"
    _standard_label.anchor_y = "center"
    _standard_label.x = 0
    _standard_label.y = 0
    _standard_label.text = text
    glPushMatrix()
    glTranslated(pos[0], pos[1], 0.0)
    glScaled(0.3, 0.3, 1)
    _standard_label.draw()
    glPopMatrix()
Esempio n. 3
0
def drawLabel(text, pos=(0,0),center=True,alpha = 75,scale=0.3,red=255,green=255,blue=255):
    _standard_label = Label(text='standard Label', font_size=200,bold=True, color=(red,green,blue,alpha))
    _standard_label.anchor_x = 'left'
    _standard_label.anchor_y = 'bottom'
    _standard_label.x = 0
    _standard_label.y = 0
    _standard_label.text = text
    glPushMatrix()
    glTranslated(pos[0], pos[1], 0.0)
    glScaled(scale,scale,1)
    _standard_label.draw()
    glPopMatrix()
Esempio n. 4
0
def drawLabel(text, pos=(0, 0), center=True):
    _standard_label = Label(text='standard Label',
                            font_size=200,
                            bold=True,
                            color=(255, 255, 255, 75))
    _standard_label.anchor_x = 'left'
    _standard_label.anchor_y = 'bottom'
    _standard_label.x = 0
    _standard_label.y = 0
    _standard_label.text = text
    glPushMatrix()
    glTranslated(pos[0], pos[1], 0.0)
    glScaled(0.3, 0.3, 1)
    _standard_label.draw()
    glPopMatrix()
Esempio n. 5
0
	def run(self):
		self.window.set_visible()
		self.window.set_mouse_visible(False)
		self.window.set_exclusive_mouse(True)

		clock = pyglet.clock.Clock()
		fps_display = Label(x=0, y=0, anchor_y="top", font_size=14)
		while not self.window.has_exit:
			self.window.dispatch_events()
			self.updateFrame()
			fps_display.text = f"FPS: {pyglet.clock.get_fps()}"
			fps_display.draw()
			self.draw()
			self.window.flip()
			
			dt = clock.tick()

		print("fps:  %d" % clock.get_fps())
Esempio n. 6
0
    def render(self, mode='human', show_sensors=False, show_trajectory=True):

        # Helper class for showing radar as cardinal direction
        class _DrawText:
            def __init__(self, label):
                self.label = label

            def render(self):
                self.label.draw()

        if self.viewer is None:

            from gym.envs.classic_control import rendering
            from gym.envs.classic_control.rendering import Transform

            self.viewer = rendering.Viewer(*self.maze_size)

            # Set up drawing for robot
            self.robot_circle = rendering.make_circle(self.ROBOT_RADIUS,
                                                      filled=False)
            self.robot_line = self.viewer.draw_line((0, 0),
                                                    (self.ROBOT_RADIUS, 0))
            self.robot_transform = Transform(translation=(0, 0), rotation=0)
            self.robot_circle.add_attr(self.robot_transform)
            self.robot_line.add_attr(self.robot_transform)
            self.viewer.add_geom(self.robot_circle)
            self.viewer.add_geom(self.robot_line)

            # Draw exit location
            self.exit = rendering.make_circle(self.EXIT_RADIUS, filled=False)
            xfrm = Transform(translation=self._reshape(self.exit_location))
            self.exit.add_attr(xfrm)
            self.viewer.add_geom(self.exit)

            # Set up for showing trajectory
            self.trajectory = []

        # Draw walls
        for wall in self.WALLS:
            self._draw_line(wall, (0, 0, 0))

        # Show sensors if indicated
        if show_sensors:

            from pyglet.text import Label

            # Show rangefinders as line segments
            for i, line in enumerate(self.rangefinder_lines):
                self._draw_line(line, (0, 1, 0) if i == 2 else (1, 0, 0))

            # Show radar as cardinal direction
            x, y = self._reshape(self.location)
            label = Label(font_size=12,
                          x=x - 5,
                          y=y,
                          anchor_x='left',
                          anchor_y='center',
                          color=(0, 0, 0, 255))
            label.text = 'FRBL'[np.argmax(self.radar)]
            self.viewer.add_onetime(_DrawText(label))

        else:

            # Draw robot
            self.robot_transform.set_translation(*self._reshape(self.location))
            self.robot_transform.set_rotation(-np.radians(self.heading))

        # Show trajectory if indicated
        if show_trajectory:
            self.trajectory.append(self.location)
            for i in range(len(self.trajectory) - 1):
                self._draw_line((self.trajectory[i], self.trajectory[i + 1]),
                                (0, 0, 1))

        return self.viewer.render(return_rgb_array=mode == 'rgb_array')