inkstitch/lib/elements/image.py

40 wiersze
1.2 KiB
Python
Czysty Zwykły widok Historia

2021-03-12 04:17:19 +00:00
# Authors: see git history
#
# Copyright (c) 2010 Authors
# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details.
2020-05-16 21:01:00 +00:00
from ..i18n import _
from ..svg.path import get_node_transform
2020-05-16 21:01:00 +00:00
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):
name = "Image"
2020-05-16 21:01:00 +00:00
def center(self):
2025-03-10 01:21:48 +00:00
parent = self.node.getparent()
assert parent is not None, "This should be part of a tree and therefore have a parent"
transform = get_node_transform(parent)
center = self.node.bounding_box(transform).center
return center
2020-05-16 21:01:00 +00:00
def validation_warnings(self):
yield ImageTypeWarning(self.center())
2025-03-10 01:21:48 +00:00
def to_stitch_groups(self, last_stitch_group, next_element):
2020-05-16 21:01:00 +00:00
return []
def first_stitch(self):
return None