kopia lustrzana https://github.com/inkstitch/inkstitch
use line join style defined in SVG
rodzic
d224b2655e
commit
1480bf73dc
|
@ -34,10 +34,11 @@ class ConvertToSatin(InkstitchExtension):
|
|||
parent = element.node.getparent()
|
||||
index = parent.index(element.node)
|
||||
correction_transform = get_correction_transform(element.node)
|
||||
style_args = self.join_style_args(element)
|
||||
|
||||
for path in element.paths:
|
||||
try:
|
||||
rails, rungs = self.path_to_satin(path, element.stroke_width)
|
||||
rails, rungs = self.path_to_satin(path, element.stroke_width, style_args)
|
||||
except ValueError:
|
||||
inkex.errormsg(_("Cannot convert %s to a satin column because it intersects itself. Try breaking it up into multiple paths.") % element.node.get('id'))
|
||||
|
||||
|
@ -50,11 +51,32 @@ class ConvertToSatin(InkstitchExtension):
|
|||
|
||||
parent.remove(element.node)
|
||||
|
||||
def path_to_satin(self, path, stroke_width):
|
||||
def join_style_args(self, element):
|
||||
"""Convert svg line join style to shapely parallel offset arguments."""
|
||||
|
||||
args = {
|
||||
'join_style': shgeo.JOIN_STYLE.round
|
||||
}
|
||||
|
||||
element_join_style = element.get_style('stroke-linejoin')
|
||||
|
||||
if element_join_style is not None:
|
||||
if element_join_style == "miter":
|
||||
args['join_style'] = shgeo.JOIN_STYLE.mitre
|
||||
|
||||
# 4 is the default per SVG spec
|
||||
miter_limit = float(element.get_style('stroke-miterlimit', 4))
|
||||
args['mitre_limit'] = miter_limit
|
||||
elif element_join_style == "bevel":
|
||||
args['join_style'] = shgeo.JOIN_STYLE.bevel
|
||||
|
||||
return args
|
||||
|
||||
def path_to_satin(self, path, stroke_width, style_args):
|
||||
path = shgeo.LineString(path)
|
||||
|
||||
left_rail = path.parallel_offset(stroke_width / 2.0, 'left')
|
||||
right_rail = path.parallel_offset(stroke_width / 2.0, 'right')
|
||||
left_rail = path.parallel_offset(stroke_width / 2.0, 'left', **style_args)
|
||||
right_rail = path.parallel_offset(stroke_width / 2.0, 'right', **style_args)
|
||||
|
||||
if not isinstance(left_rail, shgeo.LineString) or \
|
||||
not isinstance(right_rail, shgeo.LineString):
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PROJECT VERSION\n"
|
||||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||
"POT-Creation-Date: 2018-07-30 16:40-0400\n"
|
||||
"POT-Creation-Date: 2018-07-31 08:40-0400\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -248,7 +248,7 @@ msgstr ""
|
|||
msgid "Only simple lines may be converted to satin columns."
|
||||
msgstr ""
|
||||
|
||||
#: lib/extensions/convert_to_satin.py:42
|
||||
#: lib/extensions/convert_to_satin.py:43
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Cannot convert %s to a satin column because it intersects itself. Try "
|
||||
|
|
Ładowanie…
Reference in New Issue