Skip to content

Add draw_text and draw_overlay methods to Renderer#3031

Open
Shivam-Bhardwaj wants to merge 1 commit intogoogle-deepmind:mainfrom
Shivam-Bhardwaj:add-text-overlay-to-renderer
Open

Add draw_text and draw_overlay methods to Renderer#3031
Shivam-Bhardwaj wants to merge 1 commit intogoogle-deepmind:mainfrom
Shivam-Bhardwaj:add-text-overlay-to-renderer

Conversation

@Shivam-Bhardwaj
Copy link

Summary

  • Add draw_text() method to render 2D text at (x, y) coordinates with RGB color support
  • Add draw_overlay() method to render text at grid positions (top-left, bottom-right, etc.)
  • Exposes mjr_text and mjr_overlay functionality in the Python Renderer utility

Closes #1864

Test plan

  • Added unit tests for draw_text()
  • Added unit tests for draw_overlay()
  • Added test verifying text queue is cleared after render
  • Added test verifying text is not drawn in depth mode
  • Ran pyink and isort for style compliance

Example usage

with mujoco.Renderer(model, 480, 640) as renderer:
    renderer.update_scene(data, camera)
    
    # Draw colored text at position
    renderer.draw_text('Hello', x=0.5, y=0.9, rgb=(1.0, 0.0, 0.0))
    
    # Draw overlay in corner
    renderer.draw_overlay('Frame: 100', 'FPS: 60', 
                          position=mujoco.mjtGridPos.mjGRID_TOPLEFT)
    
    pixels = renderer.render()

🤖 Generated with Claude Code

@google-cla
Copy link

google-cla bot commented Jan 21, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Add text rendering capabilities to the Python Renderer class:
- draw_text(): renders 2D text at (x, y) with RGB color support
- draw_overlay(): renders text overlay at grid positions

This exposes mjr_text and mjr_overlay functionality in the Renderer
utility, addressing the feature request in issue google-deepmind#1864.
@Shivam-Bhardwaj Shivam-Bhardwaj force-pushed the add-text-overlay-to-renderer branch from 7d3ad7c to f331deb Compare January 21, 2026 04:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Print text on viewer window

1 participant