summaryrefslogtreecommitdiff
path: root/lib/svg
diff options
context:
space:
mode:
Diffstat (limited to 'lib/svg')
-rw-r--r--lib/svg/guides.py16
-rw-r--r--lib/svg/tags.py7
2 files changed, 13 insertions, 10 deletions
diff --git a/lib/svg/guides.py b/lib/svg/guides.py
index e492a90d..3329940e 100644
--- a/lib/svg/guides.py
+++ b/lib/svg/guides.py
@@ -3,11 +3,10 @@
# Copyright (c) 2010 Authors
# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details.
-from inkex import transforms
+from inkex.units import convert_unit
from ..utils import Point, cache, string_to_floats
from .tags import INKSCAPE_LABEL, SODIPODI_GUIDE, SODIPODI_NAMEDVIEW
-from .units import get_doc_size, get_viewbox_transform
class InkscapeGuide(object):
@@ -20,16 +19,15 @@ class InkscapeGuide(object):
def _parse(self):
self.label = self.node.get(INKSCAPE_LABEL, "")
- doc_size = list(get_doc_size(self.svg))
-
- # convert the size from viewbox-relative to real-world pixels
- viewbox_transform = get_viewbox_transform(self.svg)
- viewbox_transform = transforms.Transform(-transforms.Transform(viewbox_transform)).apply_to_point(doc_size)
+ doc_size = self.svg.get_page_bbox()
+ # inkscape's Y axis is reversed from SVG's, and the guide is in inkscape coordinates
self.position = Point(*string_to_floats(self.node.get('position')))
+ self.position.y = doc_size.y.size - self.position.y
- # inkscape's Y axis is reversed from SVG's, and the guide is in inkscape coordinates
- self.position.y = doc_size[1] - self.position.y
+ # convert units to px
+ unit = self.svg.unit
+ self.position.y = convert_unit(self.position.y, 'px', unit)
# This one baffles me. I think inkscape might have gotten the order of
# their vector wrong?
diff --git a/lib/svg/tags.py b/lib/svg/tags.py
index 3130bc16..66a707e9 100644
--- a/lib/svg/tags.py
+++ b/lib/svg/tags.py
@@ -11,6 +11,7 @@ inkex.NSS['inkstitch'] = 'http://inkstitch.org/namespace'
SVG_PATH_TAG = inkex.addNS('path', 'svg')
SVG_POLYLINE_TAG = inkex.addNS('polyline', 'svg')
+SVG_POLYGON_TAG = inkex.addNS('polygon', 'svg')
SVG_RECT_TAG = inkex.addNS('rect', 'svg')
SVG_ELLIPSE_TAG = inkex.addNS('ellipse', 'svg')
SVG_CIRCLE_TAG = inkex.addNS('circle', 'svg')
@@ -22,12 +23,15 @@ SVG_LINK_TAG = inkex.addNS('a', 'svg')
SVG_SYMBOL_TAG = inkex.addNS('symbol', 'svg')
SVG_USE_TAG = inkex.addNS('use', 'svg')
SVG_IMAGE_TAG = inkex.addNS('image', 'svg')
+SVG_CLIPPATH_TAG = inkex.addNS('clipPath', 'svg')
+SVG_MASK_TAG = inkex.addNS('mask', 'svg')
INKSCAPE_LABEL = inkex.addNS('label', 'inkscape')
INKSCAPE_GROUPMODE = inkex.addNS('groupmode', 'inkscape')
CONNECTION_START = inkex.addNS('connection-start', 'inkscape')
CONNECTION_END = inkex.addNS('connection-end', 'inkscape')
CONNECTOR_TYPE = inkex.addNS('connector-type', 'inkscape')
+INKSCAPE_DOCUMENT_UNITS = inkex.addNS('document-units', 'inkscape')
XLINK_HREF = inkex.addNS('href', 'xlink')
@@ -37,7 +41,8 @@ SODIPODI_ROLE = inkex.addNS('role', 'sodipodi')
INKSTITCH_LETTERING = inkex.addNS('lettering', 'inkstitch')
-EMBROIDERABLE_TAGS = (SVG_PATH_TAG, SVG_POLYLINE_TAG, SVG_RECT_TAG, SVG_ELLIPSE_TAG, SVG_CIRCLE_TAG)
+EMBROIDERABLE_TAGS = (SVG_PATH_TAG, SVG_POLYLINE_TAG, SVG_POLYGON_TAG,
+ SVG_RECT_TAG, SVG_ELLIPSE_TAG, SVG_CIRCLE_TAG)
NOT_EMBROIDERABLE_TAGS = (SVG_IMAGE_TAG, SVG_TEXT_TAG)
SVG_OBJECT_TAGS = (SVG_ELLIPSE_TAG, SVG_CIRCLE_TAG, SVG_RECT_TAG)