def write_text(self, text, position=None, font=gl_font("fixed", 13), colour=(0, 1, 0)): """ Write text on the screen. Parameters ---------- text : str The text to write. position : Optional[Sequence[int]] A sequence containing the horizontal and vertical positions, in pixels, of the lower left pixel of the first line of the text. Default is 40% of the screen right of centre, and 80% of the screen above centre. font : Optional[ctypes.c_void_p] The font to use. Default is 13-point Fixed. colour : Optional[Sequence[float]] The text colour, as RGB values between 0 and 1. Default is green. """ if position is None: x = self.width * 0.2 y = self.height * 0.4 else: x, y = position with gl_ortho(self.width, self.height): with new_state(): gl.glColor3fv(colour) gl.glRasterPos2f(x, y) glut.glutBitmapString(font, text)
def tracked_callback(self, tracked): self.tracked = tracked.data if not self.tracked: self.screen.text["tracking"] = ("Tracking lost", None, gl_font("helvetica", 18), (1, 0, 0)) elif "tracking" in self.screen.text: del self.screen.text["tracking"]