summaryrefslogtreecommitdiff
path: root/lib/elements/image.py
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2020-05-16 23:01:00 +0200
committerGitHub <noreply@github.com>2020-05-16 23:01:00 +0200
commita308db7ae152626c84ade069e307864a7e7e6213 (patch)
tree3af8a13562021796743378d16a1e7cc725ac75e4 /lib/elements/image.py
parent4e950332419743dcbaf661fdda1f7c7970241d93 (diff)
support svg objects (#643)
Diffstat (limited to 'lib/elements/image.py')
-rw-r--r--lib/elements/image.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/elements/image.py b/lib/elements/image.py
new file mode 100644
index 00000000..ec8d1765
--- /dev/null
+++ b/lib/elements/image.py
@@ -0,0 +1,34 @@
+from simpletransform import applyTransformToPoint
+
+from ..i18n import _
+from ..svg import get_node_transform
+from .element import EmbroideryElement
+from .validation import ObjectTypeWarning
+
+
+class ImageTypeWarning(ObjectTypeWarning):
+ name = _("Image")
+ description = _("Ink/Stitch can't work with objects like images.")
+ steps_to_solve = [
+ _('* Convert your image into a path: Path > Trace Bitmap... (Shift+Alt+B) '
+ '(further steps might be required)'),
+ _('* Alternatively redraw the image with the pen (P) or bezier (B) tool')
+ ]
+
+
+class ImageObject(EmbroideryElement):
+
+ def center(self):
+ point = [float(self.node.get('x', 0)), float(self.node.get('y', 0))]
+ point = [(point[0]+(float(self.node.get('width', 0))/2)), (point[1]+(float(self.node.get('height', 0))/2))]
+
+ transform = get_node_transform(self.node)
+ applyTransformToPoint(transform, point)
+
+ return point
+
+ def validation_warnings(self):
+ yield ImageTypeWarning(self.center())
+
+ def to_patches(self, last_patch):
+ return []