diff options
Diffstat (limited to 'gragl.h')
| -rw-r--r-- | gragl.h | 46 |
1 files changed, 41 insertions, 5 deletions
@@ -1,6 +1,35 @@ #ifndef GRAGL_H #define GRAGL_H +#include <stdint.h> + +typedef float ConstColor[]; +typedef float *Color; + +#define PLOT_AUTO(plot) { .function = plot, .nfuncs = sizeof(plot) / sizeof(Function), .x = 3, .y = 0, .rsize = 5, .step = 0.001 } +#define FUNC_AUTO(f) { .func = f, .color = AUTO_COLORS[(auto_color_index = (auto_color_index + 1) % 5)], .width = 3 } + +static ConstColor COLOR_RED = { 0.800f, 0.140f, 0.120f, 1.0f }; +static ConstColor COLOR_GREEN = { 0.596f, 0.592f, 0.102f, 1.0f }; +static ConstColor COLOR_YELLOW = { 0.843f, 0.600f, 0.129f, 1.0f }; +static ConstColor COLOR_BLUE = { 0.271f, 0.522f, 0.533f, 1.0f }; +static ConstColor COLOR_PURPLE = { 0.694f, 0.384f, 0.525f, 1.0f }; +static ConstColor COLOR_AQUA = { 0.408f, 0.616f, 0.416f, 1.0f }; +static ConstColor COLOR_BLACK = { 0.157f, 0.157f, 0.157f, 1.0f }; +static ConstColor COLOR_DARKER = { 0.114f, 0.125f, 0.129f, 1.0f }; +static ConstColor COLOR_WHITE = { 0.922f, 0.859f, 0.698f, 1.0f }; +static ConstColor COLOR_GRAY = { 0.659f, 0.600f, 0.518f, 1.0f }; + +static unsigned auto_color_index = 0; +static Color AUTO_COLORS[] = { + COLOR_RED, + COLOR_GREEN, + COLOR_YELLOW, + COLOR_BLUE, + COLOR_PURPLE, + COLOR_AQUA +}; + typedef struct { double x; double y; @@ -8,17 +37,24 @@ typedef struct { typedef struct { double v; - char valid; + uint8_t valid; } Scalar; typedef struct { + Scalar (*func)(double); + Color color; + double width; +} Function; + +typedef struct { unsigned width; unsigned height; - Scalar (*func)(double); - unsigned n_func; - double from; - double to; + double x; + double y; + double rsize; double step; + Function *function; + unsigned nfuncs; } Plot2d; typedef struct { |