Skip to main content
Engineering LibreTexts

8.20: makeTextObjs(), A Shortcut Function for Making Text

  • Page ID
  • def makeTextObjs(text, font, color):
        surf = font.render(text, True, color)
        return surf, surf.get_rect()

    The makeTextObjs() function just provides us with a shortcut. Given the text, Font object, and a Color object, it calls render() for us and returns the Surface and Rect object for this text. This just saves us from typing out the code to create the Surface and Rect object each time we need them.

    • Was this article helpful?