Skip to content

Commit

Permalink
* self.width is obselete
Browse files Browse the repository at this point in the history
  • Loading branch information
wanglongqi committed Nov 4, 2017
1 parent cc527cc commit 4e486e8
Showing 1 changed file with 13 additions and 27 deletions.
40 changes: 13 additions & 27 deletions writetex.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
An Latex equation editor for Inkscape.
:Author: WANG Longqi <[email protected]>
:Date: 2017-08-12
:Version: v1.6.1
:Date: 2017-11-04
:Version: v1.6.2
This file is a part of WriteTeX extension for Inkscape. For more information,
please refer to http://wanglongqi.github.io/WriteTeX.
Expand Down Expand Up @@ -71,20 +71,6 @@ def __init__(self):
help="Write output directly to a new node in svg file")

def effect(self):
# self.zoom = float(self.document.xpath(
# '//sodipodi:namedview/@inkscape:zoom', namespaces=inkex.NSS)[0])
# self.width = 1/self.zoom * \
# float(self.document.xpath(
# '//sodipodi:namedview/@inkscape:window-width', namespaces=inkex.NSS)[0])
# self.height = 1/self.zoom * \
# float(self.document.xpath(
# '//sodipodi:namedview/@inkscape:window-height', namespaces=inkex.NSS)[0])
# self.width = self.unittouu(str(self.width)+'px')
# self.height = self.unittouu(str(self.height)+'px')

self.width = 0
self.height = 0

self.options.scale = float(self.options.scale)
action = self.options.action.strip("\"")
if action == "viewold":
Expand All @@ -96,8 +82,8 @@ def effect(self):
if self.options.tosvg == "true":
doc = inkex.etree.fromstring(
'<text x="%g" y="%g">%s</text>' % (
self.view_center[0]-self.width/6,
self.view_center[1]-self.height/6,
self.view_center[0],
self.view_center[1],
node.attrib.get(
'{%s}text' % WriteTexNS, '').decode('string-escape')))
p = node.getparent()
Expand Down Expand Up @@ -236,16 +222,16 @@ def svg_to_group(self, svgin):
if self.options.rescale == 'true':
newnode.attrib['transform'] = 'matrix(%f,0,0,%f,%f,%f)' % (
800*self.options.scale, 800*self.options.scale,
self.view_center[0]-self.width/6,
self.view_center[1]-self.height/6)
self.view_center[0],
self.view_center[1])
else:
if 'transform' in node.attrib:
newnode.attrib['transform'] = node.attrib['transform']
else:
newnode.attrib['transform'] = 'matrix(%f,0,0,%f,%f,%f)' % (
800*self.options.scale, 800*self.options.scale,
self.view_center[0]-self.width/6,
self.view_center[1]-self.height/6)
self.view_center[0],
self.view_center[1])
newnode.attrib['style'] = node.attrib['style']
except:
pass
Expand All @@ -255,8 +241,8 @@ def svg_to_group(self, svgin):
else:
newnode.attrib['transform'] = 'matrix(%f,0,0,%f,%f,%f)' % (
800*self.options.scale, 800*self.options.scale,
self.view_center[0]-self.width/6,
self.view_center[1]-self.height/6)
self.view_center[0],
self.view_center[1])
self.current_layer.append(newnode)

def merge_pdf2svg_svg(self, svg_file):
Expand Down Expand Up @@ -314,8 +300,8 @@ def svg_to_group(self, svgin):
if self.options.rescale == 'true':
newnode.attrib['transform'] = 'matrix(%f,0,0,%f,%f,%f)' % (
self.options.scale, self.options.scale,
self.view_center[0]-self.width/6,
self.view_center[1]-self.height/6)
self.view_center[0],
self.view_center[1])
else:
if 'transform' in node.attrib:
newnode.attrib['transform'] = node.attrib['transform']
Expand Down Expand Up @@ -358,4 +344,4 @@ def parse_transform(transf):

if __name__ == '__main__':
e = WriteTex()
e.affect()
e.affect()

0 comments on commit 4e486e8

Please sign in to comment.