Skip to contents

Cuts out a rectangle of size width x height from the location (x, y) of an x3p object. x and y specify the bottom right corner of the rectangle. In case the dimensions of the surface matrix do not allow for the full dimensions of the rectangle cutout the dimensions are adjusted accordingly.

Usage

x3p_crop(x3p, x = 1, y = 1, width = 128, height = 128)

Arguments

x3p

x3p object

x

integer, location (in pixels) of the leftmost side of the rectangle,

y

integer, location (in pixels) of the leftmost side of the rectangle,

width

integer, width (in pixels) of the rectangle,

height

integer, height (in pixels) of the rectangle,

Value

x3p object of the cropped location expanded by list element offset that contains the coordinates of the cropped piece within the parent.

Examples

logo <- x3p_read(system.file("csafe-logo.x3p", package="x3ptools"))
# crop the x3p file to just the CSAFE logo
logo_only <- x3p_crop(logo, x=20, y=50, width = 255 ,height =310)
logo_only <- x3p_crop(logo, x=20, y=50, width = 255 ,height =510)
#> Warning: Specified dimension are adjusted to fit within range of the surface matrix: 255 x 370
# x3p_image(logo_only, size=c(500,500), zoom = 1)