Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
bevy_simple_screenshot
A plug-and-play screenshot library for Bevy 0.17+ with ring-buffered capture and automatic saving.
Quick Start
Add the dependency:
[]
= "0.1"
Add the plugin and capture screenshots from anywhere in your game code:
use *;
use *;
// Example:
// Suppose you have a system that requires screenshot functionality.
// Here is the Update function of this system.
// You can integrate the screenshot functionality in other part of the system, too.
The ScreenshotTrigger system parameter can be added to any of your game systems. Call screenshot!() whenever you want to capture - it's non-blocking and won't affect your game's performance (see benchmarks).
Screenshots are saved to .screenshots/ by default.
Entity-Focused Screenshots
Capture screenshots cropped to a specific entity (e.g., your game's hero during a special move). This is useful for:
- Character animation debugging
- Sprite sheet generation
- Isolated entity captures for thumbnails or documentation
use *;
use *;
// ─────────────────────────────────────────────────────────────
// Your existing game code (components, etc.)
// ─────────────────────────────────────────────────────────────
;
;
// ─────────────────────────────────────────────────────────────
// Add EntityScreenshotTrigger to your system parameters
// ─────────────────────────────────────────────────────────────
How It Works
- The macro reads the entity's position and size (from
SpriteorAabb) - Converts world coordinates to screen coordinates using the active 2D camera
- Captures the full window, then crops to the entity bounds + padding
- Handles HiDPI/Retina displays automatically (scales coordinates appropriately)
screenshot_entity! Variants
// Entity only (default key "default", no description, 20px padding)
screenshot_entity!;
// With key
screenshot_entity!;
// With key and description
screenshot_entity!;
// With key, description, and custom settings
let settings = default
.with_padding
.with_fallback_size; // Used if entity has no Sprite/Aabb
screenshot_entity!;
Configuration
Create screenshots.toml in your project root:
= ".screenshots"
= 10
= "png" # or "jpeg"
= true
[]
= 20
= "jpeg"
= "high" # max, high, medium, low
# Optional: burn-in text overlay on screenshots
# NOTE: font_path is REQUIRED when burn-in is enabled - see "Important Notes" below
[]
= true
= "assets/fonts/MyFont.ttf" # REQUIRED - must be a valid TTF from your project
= true # show frame number (default when enabled)
= true # show screenshot key
= true # show description text
= "upper-right" # upper-left, upper-right, lower-left, lower-right
= 5 # pixels from edge
= 18.0 # font size in pixels
Or configure programmatically:
with_config
Important Notes
Font Requirement for Burn-In
When burn-in text overlay is enabled, you must provide a valid TTF font file from your game project. The library does not bundle any fonts to keep dependencies minimal and give you full control over the appearance.
// This will PANIC if the font file doesn't exist or is invalid
enabled
.with_font // <-- Required!
If you enable burn-in without specifying a font path, or if the font file cannot be loaded, the application will panic with a clear error message. Make sure to:
- Use a font that is already part of your game's assets
- Verify the path is correct relative to your project root
- Use a standard TTF font file
Description Text Sanitization
The description parameter in screenshot!() and screenshot_entity!() is used in the output filename. To ensure valid filenames across all platforms, the description is automatically sanitized:
- Only alphanumeric characters, underscores (
_), and hyphens (-) are preserved - All other characters (spaces, special characters, non-printable characters) are removed
- Path traversal attempts (e.g.,
../) are neutralized
// These descriptions will be sanitized:
screenshot!; // -> "boss_defeated"
screenshot!; // -> "frame_100__60fps"
screenshot!; // -> "etcpasswd"
This ensures screenshots are always saved with safe, predictable filenames regardless of the description content.
Documentation
- Technical Walkthrough - Architecture, implementation details, and edge cases
- Camera Support - How 2D and 3D cameras are handled for entity screenshots
- Performance Impact - Benchmarks showing zero FPS impact across all usage scenarios
License
MIT