Mercurial > MadButterfly
changeset 80:e548221c04eb
svg2code.py support stroke
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Thu, 21 Aug 2008 00:27:36 +0800 |
parents | 5bcb329a5157 |
children | 13fdf205047b |
files | tools/mb_c_header.m4 tools/mb_c_source.m4 tools/svg2code.py |
diffstat | 3 files changed, 26 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/mb_c_header.m4 Wed Aug 20 23:47:18 2008 +0800 +++ b/tools/mb_c_header.m4 Thu Aug 21 00:27:36 2008 +0800 @@ -29,6 +29,7 @@ ]]) define([FILL_SHAPE_WITH_PAINT],) define([STROKE_SHAPE_WITH_PAINT],) +define([STROKE_WIDTH],) define([MADBUTTERFLY],[dnl [#ifndef __$1_H_
--- a/tools/mb_c_source.m4 Wed Aug 20 23:47:18 2008 +0800 +++ b/tools/mb_c_source.m4 Thu Aug 21 00:27:36 2008 +0800 @@ -41,6 +41,7 @@ define([STROKE_SHAPE]) define([FILL_SHAPE_WITH_PAINT]) define([STROKE_SHAPE_WITH_PAINT]) +define([STROKE_WIDTH]) divert[]]) define([S_ADD_LINEAR_PAINT],[ @@ -76,8 +77,8 @@ ]]) define([S_ADD_RECT],[[ - obj->$1 = sh_rect_new($2, $3, $4, $5, 0, 0); - rdman_add_shape(rdman, obj->$1, obj->$6); + obj->$1 = sh_rect_new($2, $3, $4, $5, $6, $7); + rdman_add_shape(rdman, obj->$1, obj->$8); ]]) define([S_ADD_PATH],[[ @@ -107,6 +108,10 @@ rdman_paint_stroke(rdman, obj->$1_stroke, obj->$1); ]]) +define([S_STROKE_WIDTH],[dnl +[ obj->$1->stroke_width = $2; +]]) + define([SETUP_VARS],[divert([-1]) define([SIMPORT],[IMPORT(]QUOTE($[]1)[,[S_])]) SIMPORT([ADD_LINEAR_PAINT]) @@ -121,6 +126,7 @@ SIMPORT([STROKE_SHAPE]) SIMPORT([FILL_SHAPE_WITH_PAINT]) SIMPORT([STROKE_SHAPE_WITH_PAINT]) +SIMPORT([STROKE_WIDTH],) divert[]]) define([F_ADD_LINEAR_PAINT],[[ @@ -165,6 +171,7 @@ FIMPORT([STROKE_SHAPE]) define([FILL_SHAPE_WITH_PAINT]) define([STROKE_SHAPE_WITH_PAINT]) +define([STROKE_WIDTH]) divert[]]) define([MADBUTTERFLY],[dnl
--- a/tools/svg2code.py Wed Aug 20 23:47:18 2008 +0800 +++ b/tools/svg2code.py Thu Aug 21 00:27:36 2008 +0800 @@ -147,6 +147,12 @@ raise ValueError, '\'%s\' is an invalid value for stroke.' \ % (stroke) pass + + if prop_map.has_key('stroke-width'): + stroke_width = float(prop_map['stroke-width']) + print >> codefo, 'STROKE_WIDTH([%s], %f)dnl' % ( + node_id, stroke_width) + pass pass def translate_path(path, coord_id, codefo, doc): @@ -161,11 +167,19 @@ rect_id = rect.getAttribute('id') x = float(rect.getAttribute('x')) y = float(rect.getAttribute('y')) + rx = 0.0 + if rect.hasAttribute('rx'): + rx = float(rect.getAttribute('rx')) + pass + ry = 0.0 + if rect.hasAttribute('ry'): + ry = float(rect.getAttribute('ry')) + pass width = float(rect.getAttribute('width')) height = float(rect.getAttribute('height')) print >> codefo, 'dnl' - print >> codefo, 'ADD_RECT([%s], %f, %f, %f, %f, [%s])dnl' % ( - rect_id, x, y, width, height, coord_id) + print >> codefo, 'ADD_RECT([%s], %f, %f, %f, %f, %f, %f, [%s])dnl' % ( + rect_id, x, y, width, height, rx, ry, coord_id) translate_style(rect, coord_id, codefo, doc) pass