patterns
Define Gradient and Pattern Fills
Description
Functions to define gradient fills and pattern fills.
Usage
linearGradient(colours = c("black", "white"), stops = seq(0, 1, length.out = length(colours)), x1 = unit(0, "npc"), y1 = unit(0, "npc"), x2 = unit(1, "npc"), y2 = unit(1, "npc"), default.units = "npc", extend = c("pad", "repeat", "reflect", "none")) radialGradient(colours = c("black", "white"), stops = seq(0, 1, length.out = length(colours)), cx1 = unit(.5, "npc"), cy1 = unit(.5, "npc"), r1 = unit(0, "npc"), cx2 = unit(.5, "npc"), cy2 = unit(.5, "npc"), r2 = unit(.5, "npc"), default.units = "npc", extend = c("pad", "repeat", "reflect", "none")) pattern(grob, x = 0.5, y = 0.5, width = 1, height = 1, default.units = "npc", just="centre", hjust=NULL, vjust=NULL, extend = c("pad", "repeat", "reflect", "none"), gp = gpar(fill="transparent"))
Arguments
colours | Two or more colours for the gradient to transition between. |
stops | Locations of the gradient colours between the start and end points of the gradient (as a proportion of the distance from the start point to the end point). |
x1, y1, x2, y2 | The start and end points for a linear gradient. |
default.units | The coordinate system to use if any location or dimension is specified as just a numeric value. |
extend | What happens outside the start and end of the gradient (see Details). |
cx1, cy1, r1, cx2, cy2, r2 | The centre and radius of the start and end circles for a radial gradient. |
grob | A grob (or a gTree) that will be drawn as the tile in a pattern fill. |
x, y, width, height | The size of the tile for a pattern fill. |
just, hjust, vjust | The justification of the tile relative to its location. |
gp | Default graphical parameter settings for the tile. |
Details
Use these functions to define a gradient fill or pattern fill and then use the resulting object as the value for fill
in a call to the gpar()
function.
The possible values of extend, and their meanings, are:
-
[
pad
:] propagate the value of the gradient at its boundary. -
[
none
:] produce no fill beyond the limits of the gradient. -
[
repeat
:] repeat the fill. -
[
reflect
:] repeat the fill in reverse.
To create a tiling pattern, provide a simple grob (like a circle), specify the location and size of the pattern to include the simple grob, and specify extend="repeat"
.
Value
A linear gradient or radial gradient or pattern object.
Warning
Gradient fills and pattern fills are not supported on all graphics devices. Where they are not supported, closed shapes will be rendered with a transparent fill. Where they are supported, not all values of extend
are supported.
Author(s)
Paul Murrell
See Also
Copyright (©) 1999–2012 R Foundation for Statistical Computing.
Licensed under the GNU General Public License.