grid.offsetBezier: Draw a Bezier Offset Curve.

View source: R/offsetbezier.R

grid.offsetBezierR Documentation

Draw a Bezier Offset Curve.

Description

Draw a Bezier offset curve; the main curve is described by x/y control points and offset Bezier curves are calculated to the left and right of the main curve at the specified widths.

Usage

offsetBezierGrob(x, y, w, default.units="npc", 
                 stepFn=nSteps(100), open=TRUE,
                 lineend="butt", linejoin="round", mitrelimit=4,
                 render=if (open) vwPolygon else vwPath(),
                 gp=gpar(fill="black"), name=NULL, debug=FALSE)
grid.offsetBezier(...)

Arguments

x

A numeric vector or unit describing x-locations.

y

A numeric vector or unit describing y-locations.

w

A numeric vector or unit describing widths at each location, or a width specification generated by widthSpline or a width specification generated by BezierWidth.

default.units

The units used if x or y are numeric vectors.

stepFn

Function called to generate steps in t when rendering. See Details.

open

A boolean indicating whether to connect the last location back to the first location to produce a closed line.

lineend

The line ending style; one of "round", "mitre", "butt", "square", or "extend".

linejoin

The line join style; one of "round", "mitre", "bevel", or "extend".

mitrelimit

A numeric that controls when a mitre join is converted to a bevel join or a mitre ending is converted to a square ending.

render

A function that is used to render the outline of the path that is generated for the variable-width line.

gp

A set of graphical parameters; see gpar.

name

A name for the grob generated for the variable-width line.

debug

A logical indicating whether to produce graphical debugging output.

...

Arguments passed to offsetBezierGrob.

Details

Rendering relies on flattening the spline to a series of straight line segments. This depends on generating a set of t values (and then x and y are calculated from t). The stepFn is called to generate t and given the control points, x and y as arguments, plus a range, which indicates what range of t to generate values for.

The "extend" line ending and line join style is only available if the width is specified by BezierWidth.

Value

grid.offsetBezier is used for its side-effect of drawing a variable-width line; offsetBezierGrob returns a "offsetBezierGrob" object.

Author(s)

Paul Murrell

See Also

grid.xspline, grid.vwline, grid.vwcurve, grid.brushXspline, grid.vwXspline, grid.offsetXspline

Examples

grid.newpage()
x <- c(.2, .4, .6, .8)
y <- c(-.05, .05, -.05, .05)
w <- unit(c(2, 4, 6, 8), "mm")
grid.offsetBezier(x, y + .8, w)
grid.offsetBezier(x, y + .5, w,
                  lineend="round")
grid.offsetBezier(x, y + .2, w,
                  gp=gpar(col="black"), debug=TRUE)

vwline documentation built on Sept. 11, 2024, 7:56 p.m.