Skip to content

Commit

Permalink
export nr_polygon for LinkingTo
Browse files Browse the repository at this point in the history
  • Loading branch information
coolbutuseless committed Aug 18, 2024
1 parent df88291 commit a877b77
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
26 changes: 25 additions & 1 deletion inst/include/nara.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,28 @@ static inline void nr_circle(uint32_t *nr, int height, int width, int xm, int ym

fun(nr, height, width, xm, ym, r, fill, color);
}




// void fill_polygon_c_new(uint32_t *nr, int height, int width, uint32_t color, int *x, int *y, int npoints);

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// void fill_polygon_c_new(uint32_t *nr, int height, int width, uint32_t color, int *x, int *y, int npoints);
// @param nr pointer to the integer data of a native raster
// @param height,width dimensions of nativeRaster
// @param color packed integer representing RGBA colour
// @param fill packed integer representing RGBA fill
// @param x,y integer vectors of coordinates
// @param npoints length of x and y vectors
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
static inline void nr_polygon(uint32_t *nr, int height, int width, uint32_t color, int *x, int *y, int npoints) {
static SEXP (*fun)(uint32_t *nr, int height, int width, uint32_t color, int *x, int *y, int npoints) = NULL;

if (fun == NULL) {
fun = (SEXP (*)(uint32_t *nr, int height, int width, uint32_t color, int *x, int *y, int npoints)) R_GetCCallable("nara", "nr_polygon");
}

fun(nr, height, width, color, x, y, npoints);
}


10 changes: 6 additions & 4 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ extern void draw_point_c(uint32_t *nr, int height, int width, uint32_t color, in
extern void draw_line_c(uint32_t *nr, int height, int width, uint32_t color, int x0, int y0, int x1, int y1) ;
extern void draw_point_sequence_c(uint32_t *nr, int height, int width, uint32_t color, int x1, int x2, int y);
extern void draw_circle_c(uint32_t *nr, int height, int width, int xm, int ym, int r, uint32_t fill, uint32_t color);
extern void fill_polygon_c_new(uint32_t *nr, int height, int width, uint32_t color, int *x, int *y, int npoints);

void R_init_nara(DllInfo *info) {
R_registerRoutines(
Expand All @@ -122,10 +123,11 @@ void R_init_nara(DllInfo *info) {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Make the C code available to other packages
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
R_RegisterCCallable("nara", "nr_point" , (DL_FUNC) &draw_point_c);
R_RegisterCCallable("nara", "nr_line" , (DL_FUNC) &draw_line_c);
R_RegisterCCallable("nara", "nr_hline" , (DL_FUNC) &draw_point_sequence_c);
R_RegisterCCallable("nara", "nr_circle", (DL_FUNC) &draw_circle_c);
R_RegisterCCallable("nara", "nr_point" , (DL_FUNC) &draw_point_c);
R_RegisterCCallable("nara", "nr_line" , (DL_FUNC) &draw_line_c);
R_RegisterCCallable("nara", "nr_hline" , (DL_FUNC) &draw_point_sequence_c);
R_RegisterCCallable("nara", "nr_circle" , (DL_FUNC) &draw_circle_c);
R_RegisterCCallable("nara", "nr_polygon", (DL_FUNC) &fill_polygon_c_new);
}


Expand Down

0 comments on commit a877b77

Please sign in to comment.