util.h (756B)


      1 #ifndef UTIL_H
      2 #define UTIL_H
      3 
      4 #include <stdint.h>
      5 #include <stdio.h>
      6 
      7 #define MAX(x, y) (((x) > (y)) ? (x) : (y))
      8 #define MIN(x, y) (((x) < (y)) ? (x) : (y))
      9 
     10 typedef struct {
     11     unsigned int width;
     12     unsigned int height;
     13     unsigned short *data;
     14 } scout_image_t;
     15 
     16 typedef struct {
     17     float r;
     18     float g;
     19     float b;
     20 } scout_color_t;
     21 
     22 #define HEX(hex) ( (scout_color_t){ \
     23     .r = ((float)(((hex) >> 16) & 0xFF)) / 255.0f, \
     24     .g = ((float)(((hex) >>  8) & 0xFF)) / 255.0f, \
     25     .b = ((float)( (hex)        & 0xFF)) / 255.0f \
     26 })
     27 
     28 int32_t parse_hex_color(const char *buf);
     29 scout_color_t convert_hex_color(int32_t color);
     30 
     31 char *readfile(char *path);
     32 char *fdreadfile(int fd);
     33 
     34 float exp_decay(float a, float b, float decay, float dt);
     35 
     36 #endif