Generate an HTML file that runs a raylibr R script in the browser using webR. Input features (mouse, keyboard, audio) are auto-detected from the R code.
Usage
export_html(
script,
output = NULL,
title = NULL,
width = NULL,
height = NULL,
background = "#000",
cursor = NULL
)Arguments
- script
Path to an R script file.
- output
Path for the output HTML file. Defaults to replacing the
.Rextension with.html.- title
Page title. Auto-detected from
init_window()if not specified.- width
Canvas width in pixels. Auto-detected from
init_window()if not specified.- height
Canvas height in pixels. Auto-detected from
init_window()if not specified.- background
CSS background color for the page.
- cursor
CSS cursor style for the canvas (e.g.,
"crosshair","default"). WhenNULL(the default), no cursor rule is emitted.
Value
The output file path (invisibly). Also copies required
JavaScript helper files (coi-serviceworker.js,
raylibr-host.js, raylibr-audio.js) to the output
directory if they are not already present.
Details
The generated HTML expects a repo/ subdirectory containing
the raylibr webR package built with inst/wasm/build-webr.sh.
Input features are detected by scanning the R code:
Mouse position:
get_mouse_position(), etc.Mouse buttons:
is_mouse_button_down(), etc.Keyboard (one-shot):
get_key_pressed(),is_key_pressed()Keyboard (held):
is_key_down()Text input:
gui_text_box(),get_char_pressed()Audio:
init_audio_device(),load_sound(), etc.
Key mappings are built automatically from key$... references
in the script. The JavaScript keyboard handler includes a
single-character fallback so letter, digit, and punctuation keys
work without explicit map entries.
