Creates a colored RGBA outline or halo from an image alpha
channel or a supplied mask. When image is supplied, the original image is
composited over the outline by default.
render_alpha_outline(
image = NULL,
mask = NULL,
expand = 0,
edge_softness = 0.1,
blur = 0,
gap_fill = 1,
gap_fill_alpha_threshold = 0.25,
color = "black",
alpha = 1,
pad = 0,
composite = TRUE,
filename = NULL,
preview = FALSE
)Default NULL. Image whose alpha channel will be used as the
mask. If mask is supplied, image is only used for metadata.
Default NULL. Optional logical or numeric matrix to use as the
outline mask instead of image alpha.
Default 0. Number of pixels to expand the mask.
Default 0.1. Width of the softened halo edge
transition, in pixels.
Default 0. Gaussian blur standard deviation applied to the
final outline alpha.
Default 1. Maximum alpha gap width, in pixels, to bridge
in the expanded outline alpha. This fills border-connected breaks and notches
caused by discrete distance quantization. Set to 0 to disable.
Default 0.25. Alpha threshold used to
classify border gaps. Gap filling only modifies pixels below this threshold
that are connected to the image exterior; enclosed interior holes surrounded
by pixels at or above this threshold are left unchanged.
Default "black". Outline color.
Default 1. Overall outline alpha multiplier.
Default 0. Padding in pixels before computing the outline. If
NULL, padding is computed from expand, edge_softness, and blur.
Default TRUE. If TRUE and image is supplied, composite
the outline below the original image. Set to FALSE to return the outline
alone.
Default NULL. File to save the image to. If NULL and
preview = FALSE, returns the output image.
Default FALSE. If TRUE, display the outline image.
A rayimg RGBA output image with a padding attribute.
txt = render_text_image("\U0001F409", size = 120, background_alpha = 0)
render_alpha_outline(txt, expand = 2, blur = 1, color = "purple") |>
plot_image()
#Make a rainbow outline
render_alpha_outline(txt, expand = 2, blur = 0.1, color = "darkgreen") |>
render_alpha_outline(expand = 2, blur = 0.1, color = "yellow") |>
render_alpha_outline(expand = 2, blur = 0.1, color = "orange") |>
render_alpha_outline(expand = 2, blur = 0.1, color = "red") |>
render_alpha_outline(expand = 2, blur = 0.1, color = "purple") |>
render_alpha_outline(expand = 2, blur = 0.1, color = "blue") |>
plot_image()