]> git.cworth.org Git - acre/commitdiff
Fix pixel snapping for minor ticks
authorCarl Worth <cworth@cworth.org>
Tue, 27 Jan 2009 16:24:56 +0000 (08:24 -0800)
committerCarl Worth <cworth@cworth.org>
Thu, 16 Apr 2009 19:05:27 +0000 (12:05 -0700)
It's a tiny tweak to the axis-expansion code to get it to think about
minor ticks as well as major ticks.

acre.c

diff --git a/acre.c b/acre.c
index 6cd3a0b3c309fef4d49d5bffc05601e76f520e99..8ba639ebf24e5c86321a482c6b9e2482ce3aa6d6 100644 (file)
--- a/acre.c
+++ b/acre.c
@@ -164,6 +164,7 @@ acre_add_data (acre_t *acre, acre_data_t *data)
 #define ACRE_PAD (ACRE_FONT_SIZE)
 #define ACRE_TICK_MAJOR_SIZE 6
 #define ACRE_TICK_MINOR_SIZE 3
+#define ACRE_TICK_MINOR_DIVISIONS 5
 #define ACRE_X_TICK_VALUE_PAD 2
 #define ACRE_Y_TICK_VALUE_PAD 4
 
@@ -378,7 +379,7 @@ _expand_range_for_width (double *axis_min, double *axis_max, int pixel_size)
     range = *axis_max - *axis_min;
 
     step = _step_for_range (range);
-    pixel_step = step * pixel_size / range;
+    pixel_step = step * pixel_size / range / ACRE_TICK_MINOR_DIVISIONS;
 
     /* We expand the range by the ratio of the pixel step to the floor
      * of the pixel_step.
@@ -512,14 +513,13 @@ _draw_ticks (acre_t *acre,
 {
     cairo_t *cr = acre->cr;
     double t, step, sub_step;
-    int minor_divisions = 5;
 
     cairo_save (cr);
 
     _set_transform_to_data_space (acre);
 
     step = _step_for_range (axis_max - axis_min);
-    sub_step = step / minor_divisions;
+    sub_step = step / ACRE_TICK_MINOR_DIVISIONS;
 
     for (t = (floor (axis_min / sub_step) + 1) * sub_step;
         t <= axis_max;