This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch v1
in repository evisum.

View the commit online.

commit 52284c5efa6cb727e0cd68fd2bdc40b0958e5b85
Author: Alastair Poole <[email protected]>
AuthorDate: Wed May 13 19:31:59 2026 +0100

    graph: improved support at scale > 1.0.
---
 src/bin/ui/evisum_ui_graph.c | 128 ++++++++++++++++++++++++++++++++-----------
 1 file changed, 97 insertions(+), 31 deletions(-)

diff --git a/src/bin/ui/evisum_ui_graph.c b/src/bin/ui/evisum_ui_graph.c
index c012d2c..e651f0e 100644
--- a/src/bin/ui/evisum_ui_graph.c
+++ b/src/bin/ui/evisum_ui_graph.c
@@ -2,6 +2,7 @@
 #include "evisum_ui_colors.h"
 #include <math.h>
 
+#define GRAPH_GRID_STROKE_WIDTH 1.0
 #define GRAPH_LINE_STROKE_WIDTH 1.5
 #define GRAPH_ROOT_DATA_KEY     "evisum_ui_graph_root"
 
@@ -58,6 +59,21 @@ _shape_stroke_add(Evas_Vg_Container *root, uint8_t r, uint8_t g, uint8_t b, uint
 
     evas_vg_shape_stroke_width_set(shape, width);
     evas_vg_shape_stroke_color_set(shape, r, g, b, a);
+    evas_vg_shape_stroke_cap_set(shape, EVAS_VG_CAP_BUTT);
+    evas_vg_shape_stroke_join_set(shape, EVAS_VG_JOIN_ROUND);
+    return shape;
+}
+
+static Evas_Vg_Shape *
+_shape_line_add(Evas_Vg_Container *root, uint8_t r, uint8_t g, uint8_t b, uint8_t a, double width, double x0, double y0,
+                double x1, double y1) {
+    Evas_Vg_Shape *shape;
+
+    shape = _shape_stroke_add(root, r, g, b, a, width);
+    if (!shape) return NULL;
+
+    evas_vg_shape_append_move_to(shape, x0, y0);
+    evas_vg_shape_append_line_to(shape, x1, y1);
     return shape;
 }
 
@@ -68,6 +84,11 @@ _alpha_to_u8(double alpha) {
     return (uint8_t) lround(alpha * 255.0);
 }
 
+static uint8_t
+_premul_u8(uint8_t color, uint8_t alpha) {
+    return (uint8_t) ((((unsigned int) color * (unsigned int) alpha) + 127U) / 255U);
+}
+
 static double
 _clamp_double(double value, double min, double max) {
     if (value < min) return min;
@@ -75,6 +96,27 @@ _clamp_double(double value, double min, double max) {
     return value;
 }
 
+static double
+_graph_elm_scale_get(void) {
+    double scale = elm_config_scale_get();
+
+    if (scale <= 0.0) scale = 1.0;
+    return scale;
+}
+
+static double
+_graph_layer_max_offset_get(const Evisum_Ui_Graph_Layer *layers, int layer_count) {
+    double max_offset = 0.0;
+
+    for (int i = 0; i < layer_count; i++) {
+        double offset = fabs(layers[i].offset);
+
+        if (offset > max_offset) max_offset = offset;
+    }
+
+    return max_offset;
+}
+
 static double
 _sample_y_pos(double value, double y_max, int view_y, int view_h) {
     double y;
@@ -138,9 +180,11 @@ evisum_ui_graph_draw(Evas_Object *graph_bg, Evas_Object *graph_vg, int sample_co
                      int y_grid_step_percent, double y_max, const Evisum_Ui_Graph_Series *series, int series_count,
                      const Evisum_Ui_Graph_Layer *layers, int layer_count) {
     Evas_Vg_Container *root;
-    Evas_Vg_Shape *shape;
     int gx, gy, gw, gh;
     int view_x, view_y, view_w, view_h;
+    int draw_x, draw_y, draw_w, draw_h;
+    int pad;
+    double scale, grid_stroke_width, line_stroke_width, layer_offset_scale, max_layer_offset;
     uint8_t grid_v_r, grid_v_g, grid_v_b;
     uint8_t grid_h_r, grid_h_g, grid_h_b;
 
@@ -158,38 +202,49 @@ evisum_ui_graph_draw(Evas_Object *graph_bg, Evas_Object *graph_vg, int sample_co
 
     evas_object_move(graph_vg, gx, gy);
     evas_object_resize(graph_vg, gw, gh);
+    evas_object_vg_viewbox_set(graph_vg, EINA_RECT(0, 0, gw, gh));
+    evas_object_vg_viewbox_align_set(graph_vg, 0.0, 0.0);
+
+    scale = _graph_elm_scale_get();
+    grid_stroke_width = GRAPH_GRID_STROKE_WIDTH * scale;
+    line_stroke_width = GRAPH_LINE_STROKE_WIDTH * scale;
+    layer_offset_scale = scale;
+    max_layer_offset = _graph_layer_max_offset_get(layers, layer_count) * layer_offset_scale;
+    pad = (int) ceil((line_stroke_width / 2.0) + max_layer_offset + 1.0);
+    if (pad < 1) pad = 1;
+    if ((gw - (pad * 2) < 2) || (gh - (pad * 2) < 2)) pad = 1;
 
     evisum_graph_widget_colors_get(NULL, NULL, NULL, &grid_v_r, &grid_v_g, &grid_v_b, &grid_h_r, &grid_h_g, &grid_h_b);
 
     root = _graph_root_reset(graph_vg);
     if (!root) return;
 
-    _square_grid_viewport_calc(gw, gh, sample_count, x_grid_step_samples, y_grid_step_percent, &view_x, &view_y,
+    draw_x = pad;
+    draw_y = pad;
+    draw_w = gw - (pad * 2);
+    draw_h = gh - (pad * 2);
+    if ((draw_w < 2) || (draw_h < 2)) return;
+
+    _square_grid_viewport_calc(draw_w, draw_h, sample_count, x_grid_step_samples, y_grid_step_percent, &view_x, &view_y,
                                &view_w, &view_h);
     if ((view_w < 1) || (view_h < 1)) return;
+    view_x += draw_x;
+    view_y += draw_y;
 
-    shape = _shape_stroke_add(root, grid_v_r, grid_v_g, grid_v_b, 255, 1.0);
-    if (shape) {
-        for (int sample_idx = 0; sample_idx < sample_count; sample_idx += x_grid_step_samples) {
-            int x;
-            double vx;
+    for (int sample_idx = 0; sample_idx < sample_count; sample_idx += x_grid_step_samples) {
+        int x;
 
-            x = view_x + _sample_x_pos(sample_idx, sample_count, view_w);
-            vx = (double) x + 0.5;
-            evas_vg_shape_append_move_to(shape, vx, (double) view_y);
-            evas_vg_shape_append_line_to(shape, vx, (double) (view_y + view_h - 1));
-        }
+        x = view_x + _sample_x_pos(sample_idx, sample_count, view_w);
+        _shape_line_add(root, grid_v_r, grid_v_g, grid_v_b, 255, grid_stroke_width, (double) x + 0.5, (double) view_y,
+                        (double) x + 0.5, (double) (view_y + view_h - 1));
     }
 
-    shape = _shape_stroke_add(root, grid_h_r, grid_h_g, grid_h_b, 255, 1.0);
-    if (shape) {
-        for (int percent = 0; percent <= 100; percent += y_grid_step_percent) {
-            double y;
+    for (int percent = 0; percent <= 100; percent += y_grid_step_percent) {
+        double y;
 
-            y = (double) view_y + (1.0 - ((double) percent / 100.0)) * (double) (view_h - 1) + 0.5;
-            evas_vg_shape_append_move_to(shape, (double) view_x, y);
-            evas_vg_shape_append_line_to(shape, (double) (view_x + view_w - 1), y);
-        }
+        y = (double) view_y + (1.0 - ((double) percent / 100.0)) * (double) (view_h - 1) + 0.5;
+        _shape_line_add(root, grid_h_r, grid_h_g, grid_h_b, 255, grid_stroke_width, (double) view_x, y,
+                        (double) (view_x + view_w - 1), y);
     }
 
     for (int s = 0; s < series_count; s++) {
@@ -208,33 +263,44 @@ evisum_ui_graph_draw(Evas_Object *graph_bg, Evas_Object *graph_vg, int sample_co
         for (int j = 0; j < layer_count; j++) {
             uint8_t alpha = _alpha_to_u8(layers[j].alpha);
             uint8_t pr, pg, pb;
+            Evas_Vg_Shape *shape;
             double min_y = (double) view_y;
             double max_y = (double) (view_y + view_h - 1);
             int idx;
-            double x0, y0;
+            double prev_x, prev_y;
+            Eina_Bool path_started = EINA_FALSE;
 
             if (!alpha) continue;
 
-            pr = (uint8_t) (((unsigned int) line->color_r * (unsigned int) alpha) / 255U);
-            pg = (uint8_t) (((unsigned int) line->color_g * (unsigned int) alpha) / 255U);
-            pb = (uint8_t) (((unsigned int) line->color_b * (unsigned int) alpha) / 255U);
-            shape = _shape_stroke_add(root, pr, pg, pb, alpha, GRAPH_LINE_STROKE_WIDTH);
+            pr = _premul_u8(line->color_r, alpha);
+            pg = _premul_u8(line->color_g, alpha);
+            pb = _premul_u8(line->color_b, alpha);
+            shape = _shape_stroke_add(root, pr, pg, pb, alpha, line_stroke_width);
             if (!shape) continue;
 
             idx = sample_count - count;
-            x0 = (double) view_x + (double) _sample_x_pos(idx, sample_count, view_w);
-            y0 = _sample_y_pos(line->history[start], y_max, view_y, view_h) + layers[j].offset;
-            y0 = _clamp_double(y0, min_y, max_y);
-            evas_vg_shape_append_move_to(shape, x0, y0);
+            prev_x = (double) view_x + (double) _sample_x_pos(idx, sample_count, view_w);
+            prev_y = _sample_y_pos(line->history[start], y_max, view_y, view_h)
+                     + (layers[j].offset * layer_offset_scale);
+            prev_y = _clamp_double(prev_y, min_y, max_y);
 
             for (int i = 1; i < count; i++) {
                 double x1, y1;
 
                 idx = sample_count - count + i;
                 x1 = (double) view_x + (double) _sample_x_pos(idx, sample_count, view_w);
-                y1 = _sample_y_pos(line->history[start + i], y_max, view_y, view_h) + layers[j].offset;
+                y1 = _sample_y_pos(line->history[start + i], y_max, view_y, view_h)
+                     + (layers[j].offset * layer_offset_scale);
                 y1 = _clamp_double(y1, min_y, max_y);
-                evas_vg_shape_append_line_to(shape, x1, y1);
+                if (!EINA_DBL_EQ(prev_x, x1) || !EINA_DBL_EQ(prev_y, y1)) {
+                    if (!path_started) {
+                        evas_vg_shape_append_move_to(shape, prev_x, prev_y);
+                        path_started = EINA_TRUE;
+                    }
+                    evas_vg_shape_append_line_to(shape, x1, y1);
+                }
+                prev_x = x1;
+                prev_y = y1;
             }
         }
     }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to