The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

C API

library(colorfast)

{colorfast} exports three C functions for use in other packages.

To use these functions:

void col_to_rgb(const char *col, uint8_t ptr[4]);
uint32_t col_to_int(const char *col); 
void int_to_col(uint32_t icol, char buf[10]);

String color to vector of RGBA values

void col_to_rgb(const char *col, uint8_t ptr[4])

The R call col_to_rgb('red'), can be called via the C api as:

#include <stdint.h>
#include <colorfast.h>

void convert_col_to_rgb(const char *col) {
  uint8_t values[4];
  col_to_rgb(col, values);
  
  for (int i = 0; i < 4; ++i) {
    printf("%i ", values[i]);
  }
}

String color to packed integer color

void col_to_int(const char *col)

#include <stdint.h>
#include <colorfast.h>

void convert_col_to_int(const char *col) {
  uint32_t value = col_to_int(col);
  
  printf("%i ", value);
}

Packed integer color to hexadecimal color

void int_to_col(uint32_t icol, char buf[10])

#include <stdint.h>
#include <colorfast.h>

void convert_int_to_col(uint32_t icol) {
  char buf[10];
  int_to_col(icol, buf);
  
  printf("%s\n", buf);
}

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.