https://github.com/paithiov909/etegami
An experimental viewer for 'nativeRaster' images using HTML5 canvas
https://github.com/paithiov909/etegami
Last synced: 3 months ago
JSON representation
An experimental viewer for 'nativeRaster' images using HTML5 canvas
- Host: GitHub
- URL: https://github.com/paithiov909/etegami
- Owner: paithiov909
- License: other
- Created: 2025-07-02T09:36:11.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-07-04T02:01:43.000Z (4 months ago)
- Last Synced: 2025-07-04T03:18:43.066Z (4 months ago)
- Language: TypeScript
- Homepage:
- Size: 620 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```# etegami
[](https://lifecycle.r-lib.org/articles/stages.html#experimental)
## Overview
etegami is an experimental viewer for nativeRaster images in R,
rendered on an HTML5 `` element via your browser.
It provides a lightweight mechanism for visualizing raster graphics generated in R,
particularly from graphics devices like [ragg::agg_capture()](https://ragg.r-lib.org/reference/agg_capture.html).Instead of writing out PNGs or relying on heavy viewer infrastructure,
etegami encodes nativeRaster images as JSON
containing gzipped and base64-encoded pixel data, along with the image's width, height, and an identifier.
These JSON files can be sent to the browser and decoded into [ImageData](https://developer.mozilla.org/en-US/docs/Web/API/ImageData).The viewer can:
* Load multiple JSON files and display them in sequence, like a slideshow.
* Pause and resume playback interactively.
* Capture canvas state changes and record them as a WebM animation.
## Why?
This project started as a personal exploration to make R graphics easier to work with when using VSCode.
Existing tools like [httpgd](https://github.com/nx10/httpgd) are really powerful,
but can be inflexible when switching to render raster images.Additionally, rendering to `` opened up the possibility of recording animations directly in the browser.
## Usage
Typical usage looks like this:
```r
library(etegami)# 1. Start a viewer server and prepare a capture device
postino <- setup()# 2. Draw something and capture it
plot(1:10)
last_plot <- post(postino) # manually trigger capture# 3. Open the viewer in your browser
browse(postino, last_plot)# 4. Stop the server and close the capture device
shutdown(postino)
```You can also wrap plotting calls with `mask_plot()`:
```r
postino <- setup(mode = "live")
plot <- mask_plot(postino)
plot(rnorm(100)) # automatically opens the viewer in a new window every time `plot()` is called
```