View source: R/render_image_overlay.R
| render_sprite_overlay | R Documentation |
Places an image overlay at a pixel location without resizing it to the full destination image. This is intended for sprite-like or billboard-like overlays such as labels, icons, glyphs, and screen-space annotations.
render_sprite_overlay(
image,
image_overlay = NULL,
convert_overlay_colorspace = TRUE,
alpha = NA,
overlay_coords = c(1, 1),
overlay_dims = NULL,
overlay_anchor = "nw",
overlay_just = NULL,
hjust = NULL,
vjust = NULL,
preserve_channels = TRUE,
filename = NULL,
preview = FALSE
)
image |
3-layer RGB/4-layer RGBA array, |
image_overlay |
Default |
convert_overlay_colorspace |
Default |
alpha |
Default |
overlay_coords |
Default |
overlay_dims |
Default |
overlay_anchor |
Default |
overlay_just |
Default |
hjust |
Default |
vjust |
Default |
preserve_channels |
Default |
filename |
Default |
preview |
Default |
A rayimg array.
dragon_clipped = dragon
dragon_clipped[dragon_clipped > 1] = 1
# Render a transparent dragon emoji and center it on a pixel with hjust/vjust:
dragon_emoji = render_text_image(
"\U0001F409",
size = 80,
background_alpha = 0,
use_ragg = TRUE,
trim = TRUE,
trim_padding = 8
)
render_sprite_overlay(
dragon_clipped,
image_overlay = dragon_emoji,
overlay_coords = c(ncol(dragon_clipped) / 2, nrow(dragon_clipped) / 2),
hjust = 0.5,
vjust = 0.5,
preview = TRUE
)
# The same justification can be supplied as overlay_just = c(hjust, vjust):
render_sprite_overlay(
dragon_clipped,
image_overlay = dragon_emoji,
overlay_coords = c(ncol(dragon_clipped), nrow(dragon_clipped)),
overlay_just = c(1, 1),
preview = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.