[gnome-color-manager] trivial: ensure we set the scale correctly when plotting a small number of points



commit 8c82d65dccc99e1d2cec18d19d6e476cfbb81bfc
Author: Richard Hughes <richard hughsie com>
Date:   Mon Dec 14 11:33:59 2009 +0000

    trivial: ensure we set the scale correctly when plotting a small number of points

 src/gcm-profile.c    |    2 +-
 src/gcm-trc-widget.c |    6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/src/gcm-profile.c b/src/gcm-profile.c
index c60d023..0081ced 100644
--- a/src/gcm-profile.c
+++ b/src/gcm-profile.c
@@ -1005,7 +1005,7 @@ gcm_profile_generate_curve (GcmProfile *profile, guint size)
 
 		/* create input array */
 		values_in = g_new0 (gdouble, size * 3 * component_width);
-		divamount = 1.0f / (gfloat) size;
+		divamount = 1.0f / (gfloat) (size - 1);
 		for (i=0; i<size; i++) {
 			divadd = divamount * (gfloat) i;
 
diff --git a/src/gcm-trc-widget.c b/src/gcm-trc-widget.c
index 0c32f81..02a7c2e 100644
--- a/src/gcm-trc-widget.c
+++ b/src/gcm-trc-widget.c
@@ -257,7 +257,7 @@ gcm_trc_widget_draw_line (GcmTrcWidget *trc, cairo_t *cr)
 	for (i=0; i<size; i++) {
 		tmp = g_ptr_array_index (array, (guint) i);
 		value = tmp->red/65536.0f;
-		gcm_trc_widget_map_to_display (trc, i/size, value, &wx, &wy);
+		gcm_trc_widget_map_to_display (trc, i/(size-1), value, &wx, &wy);
 		if (i == 0)
 			cairo_move_to (cr, wx, wy+1);
 		else
@@ -274,7 +274,7 @@ gcm_trc_widget_draw_line (GcmTrcWidget *trc, cairo_t *cr)
 	for (i=0; i<size; i++) {
 		tmp = g_ptr_array_index (array, (guint) i);
 		value = tmp->green/65536.0f;
-		gcm_trc_widget_map_to_display (trc, i/size, value, &wx, &wy);
+		gcm_trc_widget_map_to_display (trc, i/(size-1), value, &wx, &wy);
 		if (i == 0)
 			cairo_move_to (cr, wx, wy-1);
 		else
@@ -291,7 +291,7 @@ gcm_trc_widget_draw_line (GcmTrcWidget *trc, cairo_t *cr)
 	for (i=0; i<size; i++) {
 		tmp = g_ptr_array_index (array, (guint) i);
 		value = tmp->blue/65536.0f;
-		gcm_trc_widget_map_to_display (trc, i/size, value, &wx, &wy);
+		gcm_trc_widget_map_to_display (trc, i/(size-1), value, &wx, &wy);
 		if (i == 0)
 			cairo_move_to (cr, wx, wy);
 		else



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]