View source: R/render_text_image.R
render_text_image | R Documentation |
Generates an image which tightly fits text.
render_text_image(
text,
lineheight = 1,
color = "black",
size = 12,
font = "sans",
just = "left",
background_color = "white",
background_alpha = 1,
use_ragg = TRUE,
width = NA,
height = NA,
filename = NULL,
check_text_width = TRUE,
check_text_height = TRUE,
preview = FALSE
)
text |
Text to turn into an image. |
lineheight |
Default |
color |
Default |
size |
Default |
font |
Default |
just |
Default |
background_color |
Default |
background_alpha |
Default |
use_ragg |
Default |
width |
Default |
height |
Default |
filename |
Default |
check_text_width |
Default |
check_text_height |
Default |
preview |
Default |
A 3-layer RGB array of the processed image if filename = NULL
and preview = FALSE
.
Otherwise, writes the image to the specified file or displays it if preview = TRUE
.
if (run_documentation()) {
#Generate an image of some text
render_text_image("Some text", preview = TRUE)
}
if (run_documentation()) {
#Change the font size
render_text_image("Some text", size = 100, preview = TRUE)
}
if (run_documentation()) {
#Change the font color
render_text_image("Some text", size = 100, color="red",preview = TRUE)
}
if (run_documentation()) {
#Change the background color and transparency
render_text_image("Some text", size = 50, color="purple",
background_color="purple", background_alpha = 0.5,
preview = TRUE)
}
if (run_documentation()) {
# Plot an emoji with the agg device.
render_text_image("\U0001F600\U0001F680", size = 50, color = "purple", use_ragg = TRUE,
background_alpha = 0,
preview = TRUE)
}
if (run_documentation()) {
# Plot an emoji with the agg device and adjust the height and width (which
# is on by default) to be a tight fit.
render_text_image("\U0001F600\U0001F680", size = 50, color = "purple", use_ragg = TRUE,
background_alpha = 0, check_text_width = TRUE,
check_text_height = TRUE,
preview = TRUE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.