#ifndef GRAGL_H #define GRAGL_H #include 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; } Point2d; typedef struct { double v; uint8_t valid; } Scalar; typedef struct { Scalar (*func)(double); Color color; double width; } Function; typedef struct { unsigned width; unsigned height; double x; double y; double rsize; double step; Function *function; unsigned nfuncs; } Plot2d; typedef struct { Plot2d * plots; unsigned n; unsigned padding; } Plot2dGroup; Plot2dGroup * create_plot2d_group(int num_args, ...); void free_plot2d_group(Plot2dGroup *); void plot(Plot2dGroup *); #endif