tweak: tweak: Quick image modification.

Description Usage Arguments Details Examples

View source: R/tweak.R

Description

tweak: Quick image modification.

Recolor, add transparency, cut an image into two parts etc

Usage

1
tweak(img, color = NA, bold = NA, alpha = NA, cuts = NULL, dir = "v")

Arguments

img

pth, url, array or raster of image to transform, supports tif jpg and png

color

the color to convert to, only R colors, original colors kept if NULL

bold

set all color values to chosen color, leaves alpha untouched (0 to 1)

alpha

to add more transparency (0 to 1)

cuts

vector of relative positions of cuts (0 to 1)

dir

direction of separation

Details

Originally designed to help build infographics in R.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
img <- system.file("img", "Rlogo.png", package="png")
imgs <- list(
  tweak(img),            # original
  tweak(img,alpha=0.5),  # transparent
  tweak(img,"black"),    # greyscales
  tweak(img,"darkred"),    # any R color
  tweak(img,cuts=c(0.7),alpha = c(0,NA)),          # clean cut
  tweak(img,cuts=c(0.7),alpha = c(0.5,NA)),        #   transparency
  tweak(img,cut=c(0.33,0.66), dir = "h",
    color=c("black","gold","darkred")),      #   color on both side
  tweak(img,"darkred",bold = 1),            # make completely bold
  tweak(img,"darkred",bold = 0.3)          # make partially bold
)
showcase(imgs)

moodymudskipper/tweak documentation built on May 20, 2019, 8:49 a.m.