textgif {plothelper}R Documentation

Simple Text ".gif" File

Description

This is a wrapper of functions in package ggfittext and magick. The output is a ".gif" with changing texts and colors. Characters are automatically enlarged or shrunk.

Usage

textgif(
  text,
  text_color = NULL,
  bg_color = NULL,
  reflow = FALSE,
  width = 200,
  height = 100,
  family = "SimHei",
  fontface = 1,
  fps = 2,
  output = NULL,
  ...
)

Arguments

text

must be a character vector.

text_color

colors of the texts. Its length must be the same as that of text.

bg_color

background color of the texts. It should have the same length as text.

reflow

default is FALSE. If it is TRUE, ggfittext::geom_fit_text will automatically separate characters into several lines. However, you can separate lines manually by using line break.

width

the width of the final gif object. Default is 200. NOTE: how texts are adjusted in the text box depends on the values of width and height.

height

the height of the final gif object. Default is 100.

family

default is "SimHei" so that Chinese characters can be shown. However, some computers may not be able to use this family. And, this family ignores fontface. For Latin words, the built-in families are "serif", "sans" and "mono", and more can be found by typing "?Hershey".

fontface

1 (default) for plain, 2 for bold, 3 for italic, 4 for bold italic.

fps

the larger the faster. It should be a factor of 100, say, 2 (default), 4, 5, 10, rather than 3, 6, 7.

output

if it is NULL (default), an object is created. Otherwise, object will not only be created but also be saved with a file name (".gif") represented by this argument.

...

extra arguments used by ggfittext::geom_fit_text, e. g., angle (0 to 360), lineheight.

Examples


mytext=c("AAA", "BBB", "CCC")
color1=c("orange", "red", "white")
color2=c("black", "blue", "green")
g1=textgif(mytext, text_color=color1, bg_color=color2, 
	width=180, height=120, fps=2, family="serif")


[Package plothelper version 0.1.9 Index]