Skip to contents

curve_raw is shape_raw's "path"-geometry analog: the user supplies x/y coordinates directly, connected by straight segments in the order given, with no smoothing, resampling, or implicit closing edge. Unlike curve_line() (which requires at least two control points, since a single-point "line" isn't meaningful), curve_raw places no minimum on length(x), matching shape_raw's own leniency – it exists primarily as a convert() target for "freezing" any "path"-geometry drawable's computed points, the same role shape_raw plays for "polygon"-geometry drawables.

curve_raws() is a vectorized version of curve_raw(). Since x/y are themselves numeric vectors of vertex coordinates for a single path, curve_raws() takes them as a list() of numeric vectors instead – one vector of vertices per path.

Usage

curve_raw(x, y, id = NULL, trans = trans_identity(), ...)

curve_raws(x, y, id = NULL, trans = trans_identity(), ...)

Arguments

x, y

For curve_raw(), a numeric vector of x/y coordinates. For curve_raws(), a list() of such vectors instead – one vector of vertices per path.

id

For curve_raw(), an integer vector the same length as x/y, or NULL (the default, a single sub-path). For curve_raws(), a list() of such vectors (or NULLs) instead, one per path.

trans

A trans object applied to the curve's computed points. Default trans_identity() (no transform).

...

Arguments passed to style().

Value

A drawable.

For curve_raws(), a sketch.

Details

style@fill has no effect for curve_raw() – see drawable's geometry documentation for why "path" geometries have no interior to fill. Passing fill via ... is still accepted (it's simply ignored at draw time), since style() is shared across every geometry.

id optionally groups x/y into multiple sub-paths (see xy's own id), letting a single curve_raw() render as several disjoint strokes sharing one style.

Every other argument may be a plain vector, recycled against x/y via purrr::pmap()'s own vctrs-based rules (any length-1 element is broadcast to the common length; mismatched lengths greater than 1 raise an error). The result is a sketch containing one curve_raw() per list element/recycled row, rather than a single drawable.

Examples

draw(curve_raw(x = c(0, 1, 2), y = c(0, 1, 0)))


# useful for "freezing" a wandering path's own computed points
frozen <- S7::convert(
  curve_twist(
    x = 0, y = 0, xend = 1, yend = 0,
    path_distortion = noise_bridge(seed = 99)
  ),
  curve_raw
)
draw(frozen)


# id groups x/y into several disjoint strokes sharing one style
draw(curve_raw(
  x = c(0, 1, 2, 3), y = c(0, 1, 0, 1),
  id = c(1, 1, 2, 2)
))


draw(curve_raws(
  x = list(c(0, 1, 2), c(2, 3, 4)),
  y = list(c(0, 1, 0), c(0, 1, 0))
))