Learn R Programming

rayimage (version 0.26.1)

render_padding: Add Transparent Padding

Description

Expands an image or matrix canvas by adding constant-value padding around the original image.

Usage

render_padding(
  image,
  pad = 10,
  color = "black",
  alpha = NULL,
  filename = NULL,
  preview = FALSE
)

Value

A padded rayimg image or matrix.

Arguments

image

3-layer RGB/4-layer RGBA array, rayimg class, matrix, or filename of an image.

pad

Default 10. Padding in pixels. Use a scalar for equal padding on all sides, or c(top, right, bottom, left).

color

Default "black". Padding color. Can be a scalar, RGB/RGBA numeric vector, or R color string.

alpha

Default NULL. Padding alpha for images with an alpha channel. If NULL, uses the alpha channel supplied in color when present, otherwise defaults to 0 when color is omitted and 1 when color is supplied. Ignored for RGB and matrix inputs.

filename

Default NULL. File to save the image to. If NULL and preview = FALSE, returns the padded image.

preview

Default FALSE. If TRUE, display the padded image.

Examples

Run this code
if (FALSE) { # interactive() || identical(Sys.getenv("IN_PKGDOWN"), "true")
render_padding(dragon, pad = 20) |>
 plot_image()
}

Run the code above in your browser using DataLab