summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 461cfba)
raw | patch | inline | side by side (parent: 461cfba)
author | buliabyak <buliabyak@users.sourceforge.net> | |
Sat, 7 Feb 2009 01:58:44 +0000 (01:58 +0000) | ||
committer | buliabyak <buliabyak@users.sourceforge.net> | |
Sat, 7 Feb 2009 01:58:44 +0000 (01:58 +0000) |
share/filters/samplify.py | patch | blob | history |
index 3861112b2c235656f7195bb526472450c1e97fb5..cbd875354aad47731848746f1f60937b041990ef 100644 (file)
u'rdf' :u'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
u'inkscape' :u'http://www.inkscape.org/namespaces/inkscape',
u'xlink' :u'http://www.w3.org/1999/xlink',
-u'xml' :u'http://www.w3.org/XML/1998/namespace',
+u'xml' :u'http://www.w3.org/XML/1998/namespace'
}
# helper function to add namespace URI to a name
# attributes and elements we will use, prepared with their namespace
a_href = addNS('href', 'xlink')
+a_menu = addNS('menu', 'inkscape')
a_label = addNS('label', 'inkscape')
e_text = addNS('text', 'svg')
e_tspan = addNS('tspan', 'svg')
e_g = addNS('g', 'svg')
e_use = addNS('use', 'svg')
e_defs = addNS('defs', 'svg')
+e_filter = addNS('filter', 'svg')
e_rect = addNS('rect', 'svg')
e_svg = addNS('svg', 'svg')
e_switch = addNS('switch', 'svg')
for defs in fdoc.getroot().getchildren():
for fi in defs.getchildren():
- if fi.attrib[addNS('menu', 'inkscape')] not in menus:
- menus.append(fi.attrib[addNS('menu', 'inkscape')])
+ if fi.tag == e_filter and fi.attrib[a_menu] not in menus:
+ menus.append(fi.attrib[a_menu])
menu_shifts = {}
for m in menus:
newroot.append(text)
for defs in fdoc.getroot().getchildren():
for fi in defs.getchildren():
+ if fi.tag != e_filter:
+ continue
clone = etree.Element(e_use, nsmap=NSS)
clone.attrib[a_href]='#original'
clone.attrib["style"]='filter:url(#'+fi.attrib["id"]+')'
- menu = fi.attrib[addNS('menu', 'inkscape')]
+ menu = fi.attrib[a_menu]
clone.attrib["transform"] = 'translate('+str( q['width'] * menu_shifts[menu] )+', '+str( q['height'] * (menus.index(menu) + 1) )+')'
newroot.append(clone)
text = etree.Element(e_text, nsmap=NSS)
text.attrib['x']=str( q['x'] + q['width'] * (menu_shifts[menu] + 0.5) )
text.attrib['y']=str( q['y'] + q['height'] * (menus.index(menu) + 1.8) )
- text.attrib['style']="font-size:%d;text-anchor:middle;" % (q['height']*0.05)
+ text.attrib['style']="font-size:%d;text-anchor:middle;" % (q['height']*0.08)
text.text = fi.attrib[a_label]
newroot.append(text)