#define ACRE_FONT_SIZE 12
#define ACRE_TITLE_FONT_SIZE 32
#define ACRE_PAD (ACRE_FONT_SIZE)
-#define ACRE_TICK_SIZE 6
+#define ACRE_TICK_MAJOR_SIZE 6
+#define ACRE_TICK_MINOR_SIZE 3
#define ACRE_X_TICK_VALUE_PAD 2
#define ACRE_Y_TICK_VALUE_PAD 4
acre_ticks_t ticks)
{
cairo_t *cr = acre->cr;
- double i, step;
+ 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);
- i = (floor (axis_min / step) + 1) * step;
+ sub_step = step / minor_divisions;
- while (i <= axis_max) {
- if (ticks == ACRE_TICKS_X)
- cairo_move_to (cr, i, acre->y_axis.min);
+ for (t = (floor (axis_min / sub_step) + 1) * sub_step;
+ t <= axis_max;
+ t += sub_step)
+ {
+ int tick_size;
+ if (fabs((t / step) - (int) (t / step)) < 0.5 * (sub_step / step))
+ tick_size = ACRE_TICK_MAJOR_SIZE;
else
- cairo_move_to (cr, acre->x_axis.min, i);
+ tick_size = ACRE_TICK_MINOR_SIZE;
/* tick */
cairo_save (cr);
{
+ if (ticks == ACRE_TICKS_X)
+ cairo_move_to (cr, t, acre->y_axis.min);
+ else
+ cairo_move_to (cr, acre->x_axis.min, t);
+
cairo_identity_matrix (cr);
+
if (ticks == ACRE_TICKS_X) {
cairo_rel_line_to (cr, 0, 0.5);
- cairo_rel_line_to (cr, 0, -ACRE_TICK_SIZE-0.5);
+ cairo_rel_line_to (cr, 0, -tick_size - 0.5);
} else {
cairo_rel_line_to (cr, -0.5, 0);
- cairo_rel_line_to (cr, ACRE_TICK_SIZE+0.5, 0);
+ cairo_rel_line_to (cr, tick_size + 0.5, 0);
}
+
cairo_set_line_width (cr, 1.0);
cairo_stroke (cr);
}
cairo_restore (cr);
/* label */
- cairo_save (cr);
+ if (tick_size == ACRE_TICK_MAJOR_SIZE)
{
PangoLayout *layout;
int width, height;
- layout = _create_layout_printf (acre, "%g", i);
+ cairo_save (cr);
+
+ layout = _create_layout_printf (acre, "%g", t);
if (ticks == ACRE_TICKS_X)
- cairo_move_to (cr, i, acre->y_axis.min);
+ cairo_move_to (cr, t, acre->y_axis.min);
else
- cairo_move_to (cr, acre->x_axis.min, i);
+ cairo_move_to (cr, acre->x_axis.min, t);
cairo_identity_matrix (cr);
pango_layout_get_pixel_size (layout, &width, &height);
-height/2);
_show_layout (cr, layout);
- }
- cairo_restore (cr);
- i += step;
+ cairo_restore (cr);
+ }
}
cairo_restore (cr);