Skip to contents

Creates a hidden window, calls the supplied drawing function on a black background, and returns the captured framebuffer as an image object. The image auto-displays in knitr documents (like ggplot2 plots) and can be saved with export_image().

Usage

raylibr_screenshot(draw, width = 640L, height = 480L)

Arguments

draw

A function containing drawing calls (e.g., draw_circle, draw_text).

width

An integer. Window width in pixels.

height

An integer. Window height in pixels.

Value

An image object. On HiDPI displays the framebuffer is captured at full pixel density (e.g., 1280x960 for a 640x480 window at 2x scale); knitr still displays it at width x height.

Examples

if (FALSE) {
raylibr_screenshot(function() {
  draw_circle(200L, 150L, 80.0, "yellow")
})
}