[goffice] GOPattern: fix svg scaling.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] GOPattern: fix svg scaling.
- Date: Fri, 3 Apr 2015 01:01:55 +0000 (UTC)
commit e08c6cd0095913988a7b369ab3429edc87ac2072
Author: Morten Welinder <terra gnome org>
Date: Thu Apr 2 21:00:49 2015 -0400
GOPattern: fix svg scaling.
We must not depend on the coordinate system used in the svg file.
This scales everything to a given target size.
ChangeLog | 1 +
goffice/utils/go-pattern.c | 13 ++++++-------
2 files changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index fb05ed9..a36d858 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
* goffice/utils/go-pattern.c (go_pattern_create_cairo_pattern): Do
2 colour translations instead of 64. Split submethods into
separate functions.
+ (svg_pattern): Fix scaling.
2015-04-01 Jean Brefort <jean brefort normalesup org>
diff --git a/goffice/utils/go-pattern.c b/goffice/utils/go-pattern.c
index c75d12f..ae32024 100644
--- a/goffice/utils/go-pattern.c
+++ b/goffice/utils/go-pattern.c
@@ -313,7 +313,7 @@ legacy_pattern (GOPattern const *pattern, cairo_t *cr)
static cairo_pattern_t *
svg_pattern (GOPattern const *pattern, cairo_t *cr)
{
- double SVG_PATTERN_SCALE = 2.0;
+ int target_size = 16;
cairo_t *cr_tmp;
xmlChar *svg_path;
double width, height;
@@ -324,8 +324,7 @@ svg_pattern (GOPattern const *pattern, cairo_t *cr)
cr_surface = cairo_surface_create_similar (cairo_get_target (cr),
CAIRO_CONTENT_COLOR_ALPHA,
- width * SVG_PATTERN_SCALE,
- height * SVG_PATTERN_SCALE);
+ target_size, target_size);
cr_tmp = cairo_create (cr_surface);
@@ -333,9 +332,9 @@ svg_pattern (GOPattern const *pattern, cairo_t *cr)
cairo_paint (cr_tmp);
cairo_set_source_rgba (cr_tmp, GO_COLOR_TO_CAIRO (pattern->fore));
- cairo_scale (cr_tmp, SVG_PATTERN_SCALE, SVG_PATTERN_SCALE);
+ cairo_scale (cr_tmp, target_size / width, target_size / height);
go_cairo_emit_svg_path (cr_tmp, svg_path);
- cairo_set_line_width (cr_tmp, 0.2);
+ cairo_set_line_width (cr_tmp, 0.01);
cairo_fill (cr_tmp);
cairo_destroy (cr_tmp);
@@ -354,8 +353,8 @@ svg_pattern (GOPattern const *pattern, cairo_t *cr)
* @pattern: a #GOPattern
* @cr: a cairo context
*
- * Returns: a cairo pattern object corresponding to @pattern parameters. The returned
- * surface must be freed after use, using cairo_pattern_destroy.
+ * Returns: (transfer full): a cairo pattern object corresponding to @pattern
+ * parameters.
**/
cairo_pattern_t *
go_pattern_create_cairo_pattern (GOPattern const *pattern, cairo_t *cr)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]