cairo_polygon_vec: Draw lots of polygons

Description Usage Arguments Details See Also Examples

View source: R/cairo--bespoke.R

Description

This is a custom function to draw lots of polygons within C with a single call from R. Use this function when you want to draw lots of polygon and need to speed up the creation of the final image.

Usage

1
cairo_polygon_vec(cr, x, y, idx, r, g, b, a, sr, sg, sb, sa)

Arguments

cr

cairo_t *

x

double

y

double

idx

integer runs of the same value define the locations in the x and y vectors which refer to the same polygon.

r, g, b, a

fill colour values in range [0,1]. Set a = 0 to disable filling.

sr, sg, sb, sa

stroke colour values in range [0,1]. Set sa = 0 to disable drawing the stroke

Details

The x and y arguments must be the same length.

The colour arguments (r, g, b, a, etc) must all be the same length as the number of distinct runs of values in idx, or length of 1

See Also

Other bespoke: cairo_arc_vec(), cairo_image_surface_create_from_array(), cairo_image_surface_get_array(), cairo_image_surface_get_raster(), cairo_image_surface_get_raw(), cairo_image_surface_write_array(), cairo_polygon(), cairo_rectangle_vec(), cairo_segment_vec()

Other vectorised: cairo_arc_vec(), cairo_rectangle_vec(), cairo_segment_vec()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 
# define 2 polygons
df <- tibble::tribble(
~x, ~y, ~idx,
 0,  0,    1,
 1,  0,    1,
 1,  1,    1,
 0,  1,    1,
10,  0,   55,
11,  0,   55,
11,  1,   55,
10,  1,   55
)

# Draw 2 polygons with red fill and blue border
cairo_polygon_vec(cr, df$x, df$y, df$idx,  1, 0, 0, 1,   0, 0, 1, 1)


## End(Not run)

coolbutuseless/cairocore documentation built on Aug. 31, 2020, 12:43 a.m.