Skip to contents

Create a mask for an x3p object in case it does not have a mask yet. Masks are used for overlaying colors on the bullets surface.

Usage

x3p_add_mask(x3p, mask = NULL)

Arguments

x3p

x3p object

mask

raster matrix of colors with the same dimensions as the x3p surface. If NULL, an object of the right size will be created.

Value

x3p object with added/changed mask

Examples

x3p <- x3p_read(system.file("sample-land.x3p", package="x3ptools"))
# x3p file has mask consisting color raster image:
x3p$mask[1:5,1:5]
#>      [,1]        [,2]        [,3]        [,4]        [,5]       
#> [1,] "#57005AFF" "#57005AFF" "#57005AFF" "#57005AFF" "#57005AFF"
#> [2,] "#57005AFF" "#57005AFF" "#57005AFF" "#57005AFF" "#57005AFF"
#> [3,] "#57005AFF" "#57005AFF" "#57005AFF" "#57005AFF" "#57005AFF"
#> [4,] "#57005AFF" "#57005AFF" "#57005AFF" "#57005AFF" "#57005AFF"
#> [5,] "#57005AFF" "#57005AFF" "#57005AFF" "#57005AFF" "#57005AFF"
if (FALSE) {
logo <- x3p_read(system.file("csafe-logo.x3p", package="x3ptools"))
color_logo <- png::readPNG(system.file("csafe-color.png", package="x3ptools"))
logoplus <- x3p_add_mask(logo, as.raster(color_logo))
x3p_image(logoplus, multiply=50, size = c(741, 419),zoom = 0.5)
}