add_title: Add Title

Description Usage Arguments Value Examples

View source: R/add_title.R

Description

Takes an RGB array/filename and adds a title with an optional titlebar.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
add_title(
  image,
  title_text = "",
  title_offset = c(15, 15),
  title_color = "black",
  title_size = 30,
  title_font = "sans",
  title_style = "normal",
  title_bar_color = NULL,
  title_bar_alpha = 0.5,
  title_bar_width = NULL,
  title_position = "northwest",
  filename = NULL,
  preview = FALSE
)

Arguments

image

Image filename or 3-layer RGB array.

title_text

Default NULL. Text. Adds a title to the image, using magick::image_annotate.

title_offset

Default c(15,15). Distance from the top-left (default, gravity direction in image_annotate) corner to offset the title.

title_color

Default black. Font color.

title_size

Default 30. Font size in pixels.

title_font

Default sans. String with font family such as "sans", "mono", "serif", "Times", "Helvetica", "Trebuchet", "Georgia", "Palatino" or "Comic Sans".

title_style

Default normal. Font style (e.g. italic).

title_bar_color

Default NULL. If a color, this will create a colored bar under the title.

title_bar_alpha

Default 0.5. Transparency of the title bar.

title_bar_width

Default NULL, automatic. Width of the title bar in pixels.

title_position

Default northwest. Position of the title.

filename

Default NULL. File to save the image to. If NULL and preview = FALSE, returns an RGB array.

preview

Default FALSE. If TRUE, it will display the image in addition to returning it.

Value

3-layer RGB array of the processed image.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
if(interactive()){
#Plot the dragon

add_title(dragon, preview = TRUE, title_text = "Dragon", title_size=20)

#That's hard to see--let's add a title bar:

add_title(dragon, preview = TRUE, title_text = "Dragon", title_size=20,
         title_bar_color="white")


#Change the width of the bar:

add_title(dragon, preview = TRUE, title_text = "Dragon", title_size=20,
         title_bar_color="white", title_offset = c(12,12))

#Change the color and title color:

add_title(dragon, preview = TRUE, title_text = "Dragon", title_size=20,
         title_bar_color="red", title_color = "white", title_offset = c(12,12))


#Change the transparency:

add_title(dragon, preview = TRUE, title_text = "Dragon", title_size=20, title_bar_alpha = 0.8,
         title_bar_color="red", title_color = "white", title_offset = c(12,12))

}

rayimage documentation built on June 27, 2021, 5:07 p.m.

Related to add_title in rayimage...