aboutsummaryrefslogtreecommitdiff
path: root/gragl.h
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2023-11-09 02:17:39 +0100
committerNathan Reiner <nathan@nathanreiner.xyz>2023-11-09 02:17:39 +0100
commit87a70d198b1361b6c9601e61fef6b58071bbd0a8 (patch)
tree4984b93437a13d6f9fac8876e9e39cf0a78bbebb /gragl.h
parent0dca2c3e51c98dfa9e62cddd32cadbf6c7f71a3d (diff)
add interactivity and shared libHEADv0.0.1master
Diffstat (limited to 'gragl.h')
-rw-r--r--gragl.h46
1 files changed, 41 insertions, 5 deletions
diff --git a/gragl.h b/gragl.h
index 6c6c8a7..b0082cb 100644
--- a/gragl.h
+++ b/gragl.h
@@ -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 {