Add background color radial gradients

add_background_gradient(
  input,
  colors = c("white", "black"),
  stops = seq(0, 1, length.out = length(colors)),
  center_x = 0.5,
  center_y = 0.5,
  focus_x = 0.5,
  focus_y = 0.5,
  radius = sqrt(2),
  rounding = 0,
  openfile = TRUE,
  output = input
)

Arguments

input

File name of .svg file to input

colors

Vector of gradient colors

stops

Vector of stops for gradient colors. Ranges from 0 to 1.

center_x

x-coordinate for center of gradient. Number between 0 and 1.

center_y

y-coordinate for center of gradient. Number between 0 and 1.

focus_x

x-coordinate for focus of gradient. Number between 0 and 1.

focus_y

y-coordinate for focus of gradient. Number between 0 and 1.

radius

Radius of radial gradient. The default is the square root of 2 so that the gradient extends to the corners of the square. If you want it to extend to the edges, set it to 1.

rounding

Rounding of background rectangle's corners. The default is 0 (no rounding). A rounding value of 1 creates a circle. If rounding is a vector of 2 values, the x and y rounding parameters are set separately.

openfile

Open file in default program for .svg format. Defaults to FALSE.

output

File name of .svg file to output. Default is to overwrite the input file.

Value

output name

Examples

.old_wd <- setwd(tempdir()) library(spiro) spiro( fixed_radius = 3, cycling_radius = 1, file = "add_background_gradient.svg" ) %>% add_background_gradient(color = c("black","white")) setwd(.old_wd)