Nothing
knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(nara) library(callme)
C function declaration for drawing a line on a native raster
void nr_line(uint32_t *nr, int nr_width, int nr_height, int x1, int y1, int x2, int y2, uint32_t color, double linewidth);
nr is a uint32_t pointer to the native raster datanr_width and nr_height are the number of columns and rows of the rasterx1, y1, x2, y2 are the integer coordinates of the endpoints of the linecolor is a packaged integer color of the form 0xAABBGGRRu. See also the {colorfast} package.code <- r"( #include <stdint.h> #include "nara.h" SEXP my_func(SEXP nr_) { int nr_width = Rf_ncols(nr_); int nr_height = Rf_nrows(nr_); uint32_t *nr = (uint32_t *)INTEGER(nr_); uint32_t col = 0xFF0000FFu; // 0xAABBGGRR Red bool use_alpha = true; // nr, nr_width, nr_height, x1, y1, x2, y2, color, linewidth, use_alpha nr_line(nr, nr_width, nr_height, 0, 0, 200, 150, col , 1, use_alpha); return nr_; } )" #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Find the location of nara.h and include its directory in the search path # using C Pre-Processor flags (PKG_CPPFLAGS) #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ nara_h <- system.file("include/private/nara.h", package = "nara", mustWork = TRUE) cpp_include = paste0("-I", dirname(nara_h)) callme::compile(code, PKG_CPPFLAGS = cpp_include) #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Create a native raster and call my function #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ nr <- nr_new(400, 300, 'grey70') nr <- my_func(nr) plot(nr)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.