X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=acre.c;h=5177419ae1b8c7b203851a4878e3d6201101840b;hb=15f50e0679a920781b3a7d00ad1156b452e14a8f;hp=e3604dcff6a8de23ed264edc96bbeeaf374ee0fa;hpb=803fba5eca929a4e0cb541223182eae86a96f9bb;p=acre diff --git a/acre.c b/acre.c index e3604dc..5177419 100644 --- a/acre.c +++ b/acre.c @@ -347,6 +347,9 @@ _create_layout (acre_t *acre, const char *text) { PangoLayout *layout; + if (text == NULL) + text = ""; + layout = pango_cairo_create_layout (acre->cr); pango_layout_set_font_description (layout, acre->font); pango_layout_set_text (layout, text, -1); @@ -699,23 +702,6 @@ _compute_axis_ranges (acre_t *acre) } } - /* Next, we want to ensure that the data never collides with the - * ticks. So we expand each axis on its minimum side as needed. */ - cairo_save (cr); - { - double x, y; - - _set_transform_to_data_space (acre); - - x = ACRE_TICK_MAJOR_SIZE + 2.0; - y = ACRE_TICK_MAJOR_SIZE + 2.0; - cairo_device_to_user_distance (cr, &x, &y); - - acre->x_axis.view_min -= x; - acre->y_axis.view_min += y; - } - cairo_restore (cr); - /* Then, increase the axis ranges just enough so that the step * sizes for the ticks will be integers. */ @@ -750,55 +736,6 @@ _compute_axis_ranges (acre_t *acre) cairo_restore (cr); } -static void -_acre_color_from_hsv (acre_color_t *color, - double hue, - double saturation, - double value) -{ - double f, p, q, t; - int hmod6; - - hmod6 = (int) floor (hue / 60) % 6; - f = hue / 60 - floor (hue / 60); - p = value * (1 - saturation); - q = value * (1 - f * saturation); - t = value * (1 - (1 - f) * saturation); - - switch (hmod6) { - case 0: - color->red = value; - color->green = t; - color->blue = p; - break; - case 1: - color->red = q; - color->green = value; - color->blue = p; - break; - case 2: - color->red = p; - color->green = value; - color->blue = t; - break; - case 3: - color->red = p; - color->green = q; - color->blue = value; - break; - case 4: - color->red = t; - color->green = p; - color->blue = value; - break; - case 5: - color->red = value; - color->green = p; - color->blue = q; - break; - } -} - static void _choose_colors (acre_t *acre) { @@ -848,10 +785,14 @@ _draw_data (acre_t *acre) cairo_t *cr = acre->cr; unsigned int d, i; acre_data_t *data; - bool pen_up; cairo_save (cr); + cairo_rectangle (cr, + acre->chart.x, acre->chart.y, + acre->chart.width, acre->chart.height); + cairo_clip (cr); + cairo_set_source_rgb (cr, 0, 0, 0); _set_transform_to_data_space (acre); @@ -864,28 +805,12 @@ _draw_data (acre_t *acre) acre->colors[color].blue); data = acre->data[d]; - pen_up = true; cairo_new_path (cr); for (i = 0; i < data->num_points; i++) { - if (data->points[i].x >= acre->x_axis.view_min && - data->points[i].x <= acre->x_axis.view_max && - data->points[i].y >= acre->y_axis.view_min && - data->points[i].y <= acre->y_axis.view_max) - { - if (pen_up) - cairo_move_to (cr, - data->points[i].x, - data->points[i].y); - else - cairo_line_to (cr, - data->points[i].x, - data->points[i].y); - - pen_up = false; - } else { - pen_up = true; - } + cairo_line_to (cr, + data->points[i].x, + data->points[i].y); } cairo_save (cr); {