[lasem] [SVG] Fix the dashed strokes.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: svn-commits-list gnome org
- Subject: [lasem] [SVG] Fix the dashed strokes.
- Date: Fri, 15 May 2009 18:14:10 -0400 (EDT)
commit 39fd0367197089d863f6323e6598173adf3aa61e
Author: Emmanuel Pacaud <emmanuel pacaud lapp in2p3 fr>
Date: Sat May 16 00:13:29 2009 +0200
[SVG] Fix the dashed strokes.
---
src/lsmsvgattributes.c | 12 ++++++------
src/lsmsvgattributes.h | 2 +-
src/lsmsvgview.c | 15 +++++++++++++--
3 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/src/lsmsvgattributes.c b/src/lsmsvgattributes.c
index 0333247..8f98d6d 100644
--- a/src/lsmsvgattributes.c
+++ b/src/lsmsvgattributes.c
@@ -41,7 +41,7 @@ lsm_svg_dash_array_new (unsigned int n_dashes)
array = g_new (LsmSvgDashArray, 1);
if (array != NULL) {
array->n_dashes = n_dashes;
- array->dashes = g_new (double, n_dashes);
+ array->dashes = g_new (LsmSvgLength, n_dashes);
if (array->dashes != NULL)
return array;
g_free (array);
@@ -209,13 +209,13 @@ lsm_svg_dash_array_attribute_parse (LsmSvgDashArrayAttribute *attribute,
for (i = 0; i < n_dashes; i++) {
if (lsm_svg_str_parse_double (&iter, &length.value_unit)) {
length.type = lsm_svg_length_type_from_string (iter);
- /* FIXME */
- attribute->value->dashes[i] = 0.0;
-/* lsm_svg_length_compute (&length, style, direction);*/
+ attribute->value->dashes[i] = length;
while (*iter != '\0' && *iter != ' ' && *iter != ',')
iter ++;
- } else
- attribute->value->dashes[i] = 0.0;
+ } else {
+ attribute->value->dashes[i].value_unit = 0.0;
+ attribute->value->dashes[i].value_unit = LSM_SVG_LENGTH_TYPE_NUMBER;
+ }
lsm_svg_str_skip_comma_and_spaces (&iter);
}
}
diff --git a/src/lsmsvgattributes.h b/src/lsmsvgattributes.h
index eaa81f1..65a204f 100644
--- a/src/lsmsvgattributes.h
+++ b/src/lsmsvgattributes.h
@@ -47,7 +47,7 @@ extern const LsmSvgColor lsm_svg_color_null;
typedef struct {
unsigned int n_dashes;
- double *dashes;
+ LsmSvgLength *dashes;
} LsmSvgDashArray;
extern const LsmSvgDashArray lsm_svg_dash_array_null;
diff --git a/src/lsmsvgview.c b/src/lsmsvgview.c
index 2479a16..c91542c 100644
--- a/src/lsmsvgview.c
+++ b/src/lsmsvgview.c
@@ -912,16 +912,27 @@ _paint (LsmSvgView *view)
cairo_set_miter_limit (cairo, stroke->miter_limit.value);
cairo_set_line_width (cairo, line_width);
- if (stroke->dash_array.value != NULL) {
+ if (stroke->dash_array.value != NULL &&
+ stroke->dash_array.value->n_dashes > 0) {
double dash_offset;
+ double *dashes;
+ unsigned int i;
dash_offset = lsm_svg_view_normalize_length (view, &stroke->dash_offset.length,
LSM_SVG_LENGTH_DIRECTION_DIAGONAL);
+ dashes = g_new(double, stroke->dash_array.value->n_dashes);
+ for (i = 0; i < stroke->dash_array.value->n_dashes; i++)
+ dashes[i] = lsm_svg_view_normalize_length (view,
+ &stroke->dash_array.value->dashes[i],
+ LSM_SVG_LENGTH_DIRECTION_DIAGONAL);
+
cairo_set_dash (cairo,
- stroke->dash_array.value->dashes,
+ dashes,
stroke->dash_array.value->n_dashes,
dash_offset);
+
+ g_free (dashes);
} else
cairo_set_dash (cairo, NULL, 0, 0.0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]