aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--color.h8
-rw-r--r--main.c6
-rw-r--r--renderer.c3
-rw-r--r--ui.c24
-rw-r--r--widget.c3
6 files changed, 37 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index ab9d5ce..5c9c101 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@ LDFLAGS = -lSDL2 -lSDL2_ttf -lSDL2_image -lm -fopenmp
SRC = main.c microui.c renderer.c widget.c ui.c unit.c engine.c compressor.c eprintf.c cwalk.c toml.c util.c
OBJ = ${SRC:.c=.o}
-HDR = microui.h renderer.h widget.h ui.h unit.h engine.h eprintf.h util.h cwalk.h toml.h
+HDR = microui.h renderer.h widget.h ui.h unit.h engine.h eprintf.h util.h cwalk.h toml.h color.h
TEST_SRC = test.c test_angular_speed.c test_fraction.c test_pressure.c test_temperature.c test_volume.c test_volume_flow_rate.c test_mass_flow_rate.c test_engine.c unit.c engine.c
TEST_OBJ = ${TEST_SRC:.c=.o}
diff --git a/color.h b/color.h
new file mode 100644
index 0000000..7de787a
--- /dev/null
+++ b/color.h
@@ -0,0 +1,8 @@
+static const mu_Color BLACK = {0, 0, 0, 255};
+static const mu_Color WHITE = {255, 255, 255, 255};
+static const mu_Color LIGHT_GRAY = {222, 222, 222, 255};
+static const mu_Color DARK_GRAY = {128, 128, 128, 255};
+static const mu_Color RED = {255, 0, 0, 255};
+static const mu_Color GREEN = {0, 255, 0, 255};
+static const mu_Color BLUE = {0, 0, 255, 255};
+static const mu_Color TRANSPARENT = {0, 0, 0, 0};
diff --git a/main.c b/main.c
index a869d57..cc1620f 100644
--- a/main.c
+++ b/main.c
@@ -11,6 +11,7 @@
#include "widget.h"
#include "engine.h"
#include "ui.h"
+#include "color.h"
/* Macros. */
@@ -26,11 +27,6 @@ enum window {
};
-static const mu_Color BLACK = {0, 0, 0, 255};
-static const mu_Color WHITE = {255, 255, 255, 255};
-static const mu_Color LIGHT_GRAY = {222, 222, 222, 255};
-static const mu_Color DARK_GRAY = {128, 128, 128, 255};
-
static const mu_Color COLOR_TEXT = BLACK;
static const mu_Color COLOR_BORDER = BLACK;
static const mu_Color COLOR_WINDOWBG = WHITE;
diff --git a/renderer.c b/renderer.c
index c40fcf8..6cda9d1 100644
--- a/renderer.c
+++ b/renderer.c
@@ -7,6 +7,7 @@
#include <SDL2/SDL_image.h>
#include "microui.h"
#include "renderer.h"
+#include "color.h"
#define expect(x) do { \
@@ -41,7 +42,7 @@ enum { CIRCLE_RADIUS = 16 };
static const char FONT[] = "font/P052-Roman.ttf";
enum font { FONTSIZE = 14, };
-static const mu_Color bg = {255, 255, 255, 255};
+static const mu_Color bg = WHITE;
static const char button_map[256] = {
[SDL_BUTTON_LEFT & 0xff] = MU_MOUSE_LEFT,
diff --git a/ui.c b/ui.c
index 77daf2a..10466dd 100644
--- a/ui.c
+++ b/ui.c
@@ -12,6 +12,7 @@
#include "engine.h"
#include "ui.h"
#include "eprintf.h"
+#include "color.h"
#define DEFAULT_DISPLACEMENT (litre(1.5))
@@ -24,6 +25,10 @@
#define DEFAULT_INTERCOOLER_EFFICIENCY (percent(90))
#define DEFAULT_INTERCOOLER_DELTAP (psi(0.2))
+enum { POINT_RADIUS = 8 };
+
+static const mu_Color POINT_COLOR = RED;
+
static void init_displacement(UI *ui);
static void init_ambient_temperature(UI *ui);
@@ -48,6 +53,8 @@ static void compute_manifold_temperature(UI *ui, int idx);
static void compute_volume_flow_rate(UI *ui, int idx);
static void compute_mass_flow_rate(UI *ui, int idx);
static void compute_mass_flow_rate_corrected(UI *ui, int idx);
+static void draw_point(UI *ui, int idx, mu_Color color);
+static void point_coords(UI *ui, int idx, int *x, int *y);
/* Returns non-zero on error. The renderer must already be initialized. */
@@ -427,12 +434,16 @@ set_intercooler_deltap_unit(UI *ui) {
void
compute(UI *ui, int idx) {
+ draw_point(ui, idx, TRANSPARENT);
+
compute_pressure_ratio(ui, idx);
compute_comp_outlet_temperature(ui, idx);
compute_manifold_temperature(ui, idx);
compute_volume_flow_rate(ui, idx);
compute_mass_flow_rate(ui, idx);
compute_mass_flow_rate_corrected(ui, idx);
+
+ draw_point(ui, idx, POINT_COLOR);
}
void
@@ -522,6 +533,19 @@ compute_mass_flow_rate_corrected(UI *ui, int idx) {
w_set_number(ui->mass_flow_rate_corrected[idx], v);
}
+static void
+draw_point(UI *ui, int idx, mu_Color color) {
+ int x, y;
+
+ point_coords(ui, idx, &x, &y);
+ w_canvas_draw_circle(&ui->comp_img, x, y, POINT_RADIUS, color);
+}
+
+static void
+point_coords(UI *ui, int idx, int *x, int *y) {
+ /* TODO */
+}
+
void
insert_point(UI *ui, int idx) {
int i;
diff --git a/widget.c b/widget.c
index 7380793..da16597 100644
--- a/widget.c
+++ b/widget.c
@@ -12,12 +12,11 @@
#include "widget.h"
#include "util.h"
#include "eprintf.h"
+#include "color.h"
#define FORMAT "%.5g"
-static const mu_Color RED = {255, 0, 0, 255};
-static const mu_Color WHITE = {255, 255, 255, 255};
static const char *sc_selected_name(w_Select_Compressor *select);
static int select_compressor_active(mu_Context *ctx, w_Select_Compressor *select);