[goffice] Patterns: handle greys as solids.



commit 148b6b9c7c1369c84853cb676a8d123e4860d505
Author: Morten Welinder <terra gnome org>
Date:   Tue Mar 26 15:40:05 2013 -0400

    Patterns: handle greys as solids.

 ChangeLog                  |    2 ++
 NEWS                       |    1 +
 goffice/utils/go-pattern.c |   26 ++++++++++++++++++++++----
 3 files changed, 25 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 5e7fb04..788734e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2013-03-26  Morten Welinder  <terra gnome org>
 
+       * goffice/utils/go-pattern.c (go_pattern_is_solid): Handle greys.
+
        * goffice/canvas/goc-group.c (goc_group_add_child): Only notify of
        canvas changes when the canvas actually does change.
 
diff --git a/NEWS b/NEWS
index 5d2a7b7..157eba5 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,7 @@ Morten:
        * Fix GOComboColor signal problem.  [#696022]
        * Plug leaks.
        * Enhance canvas with posibility of css.
+       * Improve printing of grey patterns.
 
 --------------------------------------------------------------------------
 goffice 0.10.1:
diff --git a/goffice/utils/go-pattern.c b/goffice/utils/go-pattern.c
index abc2e93..3a9b20c 100644
--- a/goffice/utils/go-pattern.c
+++ b/goffice/utils/go-pattern.c
@@ -139,17 +139,34 @@ go_pattern_as_str (GOPatternType pattern)
 gboolean
 go_pattern_is_solid (GOPattern const *pat, GOColor *color)
 {
+       GOPatternType p;
+
        g_return_val_if_fail (pat != NULL, FALSE);
 
-       if (pat->pattern == GO_PATTERN_SOLID || pat->fore == pat->back) {
-               *color = pat->back;
+       p = pat->pattern;
+       if (pat->fore == pat->back)
+               p = GO_PATTERN_SOLID;
+
+       switch (p) {
+       case GO_PATTERN_GREY75:
+       case GO_PATTERN_GREY50:
+       case GO_PATTERN_GREY25:
+       case GO_PATTERN_GREY125:
+       case GO_PATTERN_GREY625: {
+               static double const grey[] = { -1, 0.75, 0.50, 0.25, 0.125, 0.0625 };
+               double g = grey[p];
+               *color = GO_COLOR_INTERPOLATE (pat->back, pat->fore, g);
                return TRUE;
        }
-       if (pat->pattern == GO_PATTERN_FOREGROUND_SOLID) {
+       case GO_PATTERN_SOLID:
+               *color = pat->back;
+               return TRUE;
+       case GO_PATTERN_FOREGROUND_SOLID:
                *color = pat->fore;
                return TRUE;
+       default:
+               return FALSE;
        }
-       return FALSE;
 }
 
 /**
@@ -256,6 +273,7 @@ go_pattern_create_cairo_pattern (GOPattern const *pattern, cairo_t *cr)
 
        if (go_pattern_is_solid (pattern, &color)) {
                cr_pattern = cairo_pattern_create_rgba (GO_COLOR_TO_CAIRO (color));
+
 #if 0
                /* This code is disabled for now. Cairo export of vector pattern
                 * to PDF or PS looks terrible, and even SVG export is not properly rendered


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