Gradient Objects | R Documentation |
Create objects which describe linear and radial gradients. These objects can later be used to apply a gradient fill to grobs, and also to define a gradient so that it may be reused multiple times.
linearGradient(col = c("black", "white"),
stops = seq(0, 1, length.out = length(col)),
gradientUnits = c("bbox", "coords"),
x0 = unit(0, "npc"), x1 = unit(1, "npc"),
y0 = unit(0, "npc"), y1 = unit(1, "npc"),
default.units = "npc",
spreadMethod = c("pad", "reflect", "repeat"))
radialGradient(col = c("black", "white"),
stops = seq(0, 1, length.out = length(col)),
gradientUnits = c("bbox", "coords"),
x = unit(0.5, "npc"), y = unit(0.5, "npc"),
r = unit(0.5, "npc"),
fx = unit(0.5, "npc"), fy = unit(0.5, "npc"),
default.units = "npc",
spreadMethod = c("pad", "reflect", "repeat"))
col |
A vector of colours used for gradient stops. |
stops |
A numeric vector of offsets (typically between 0 and 1) to place the
the colours ( |
gradientUnits |
If If |
x0 |
Numeric or unit object indicating the starting x-location of the linear gradient. |
x1 |
Numeric or unit object indicating the stopping x-location of the linear gradient. |
y0 |
Numeric or unit object indicating the starting y-location of the linear gradient. |
y1 |
Numeric or unit object indicating the stopping y-location of the linear gradient. |
x |
Numeric or unit object indicating the x-location of the radial gradient. |
y |
Numeric or unit object indicating the y-location of the radial gradient. |
r |
A numeric vector or unit object specifying the radius of the radial gradient. |
fx |
A numeric vector or unit object specifying an x-location. Determines the x-location of the focal point of the radial gradient. |
fy |
A numeric vector or unit object specifying an y-location. Determines the y-location of the focal point of the radial gradient. |
default.units |
A string indicating the default units to use if |
spreadMethod |
A character vector determining when happens when a gradient begins or ends within its bounds. See details. |
When defining gradient stops via col
and stops
, the
order is important. Gradient stops which are defined earlier are drawn
first, with later stops being drawn over the top.
For spreadMethod
the possible values are:
pad Use the terminal colors of the gradient to fill the remainder of the target region.
reflect Reflect the gradient pattern start-to-end, end-to-start, start-to-end, etc. continuously until the target region is filled.
repeat Repeat the gradient pattern start-to-end, start-to-end, start-to-end, etc. continuously until the target region is filled.
A gradient
object.
Simon Potter
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.