Skip to contents

Add padding to sides of stimuli. This is a convenience function to calculate offsets for crop().

Usage

pad(stimuli, top = 10, right = top, bottom = top, left = right, ...)

Arguments

stimuli

list of stimuli

top, right, bottom, left

number of pixels or proportion (<1) to pad each side

...

additional arguments to pass to crop()

Value

list of stimuli

Details

The value for top is copied to bottom and right, and the value for right is copied to left, so setting only top produces a consistent border, while setting just top and right sets different borders for top-bottom and right-left. (This convention will be familiar if you use CSS.)

Padding size values are interpreted as a proportion of width or height if less than 1.

See also

Stimulus manipulation functions align(), crop_tem(), crop(), greyscale(), horiz_eyes(), image_func(), mask_oval(), mask(), mirror(), resize(), rotate(), to_size()

Examples

stimuli <- demo_stim()

# default 10-pixel padding
pad(stimuli, fill = "dodgerblue")


# \donttest{
# change pad width and set fill
pad(stimuli, 2, fill = "dodgerblue")


# set top border to 10% height
# different colour for each image
pad(stimuli, 0.1, 1, 1, 1,
    fill = c("hotpink", "dodgerblue"))

# }