Skip to contents

The viz_radialGradient function creates an SVG radialGradient definition and adds it to the SVG defs. It returns a reference usable in SVG styling (e.g. url(#id)). It is typically used to create smooth radial color transitions.

Usage

viz_radialGradient(
  map,
  id = NULL,
  color1 = "#63b0af",
  color2 = "#428c8b",
  offset1 = 50,
  offset2 = 100,
  fx = 50,
  fy = 50,
  ...
)

Arguments

map

A geoviz map created with viz_create.

id

character. Optional. Unique gradient id.

color1

character. Optional. First color of the gradient (default "#63b0af").

color2

character. Optional. Second color of the gradient (default "#428c8b").

offset1

numeric. Optional. Offset of the first color stop (default 50).

offset2

numeric. Optional. Offset of the second color stop (default 100).

fx

numeric. Optional. Focal point x-position (default 50).

fy

numeric. Optional. Focal point y-position (default 50).

...

Additional parameters

Examples

library(sf)
world <- st_read(
  system.file("gpkg/world.gpkg", package = "geoviz"),
  quiet = TRUE
)
aus <- world[world$ISO3 == "AUS", ]

viz_create() |>
viz_radialGradient(
  id = "my_gradient", color1 = "#63b0af",
  color2 = "#428c8b"
) |>
viz_path(datum = aus, fill = "url(#my_gradient)") |>
viz_render()