kopia lustrzana https://github.com/inkstitch/inkstitch
new extension: split satin (#315)
This branch adds a new command to split a satin column at a specified point. The split happens at a stitch boundary to ensure that the two resulting satins sew just like the original. All parameters set on the original satin remain set on the two new satins, and all rungs are retained. If one of the satins would have no rungs left, a new rung is added. How to use: 1. Select a satin column (simple satin doesn't work) 2. Attach the "Satin split point" command using the "Attach commands to selected objects" extension. 3. Move the symbol (or just the connector line's endpoint) to point to the exact spot you want the satin to be split at. 4. Select the satin column again. 5. Run "Split Satin Column". 6. The split point command and connector line disappear, and nothing else appears to have happened. Select your satin and you'll see that it's been split. This extension is a by-product of my initial work on #214. Ink/Stitch will need the ability to split a satin at an arbitrary point, and I figured, why not go ahead and release that functionality as an extension while I'm at it? :)pull/338/head
rodzic
5139c13fd7
commit
8830eb7d40
|
|
@ -24,6 +24,10 @@ COMMANDS = {
|
|||
# L10N command attached to an object
|
||||
N_("ignore_object"): N_("Ignore this object (do not stitch)"),
|
||||
|
||||
# L10N command attached to an object
|
||||
N_("satin_cut_point"): N_("Satin cut point (use with Cut Satin Column)"),
|
||||
|
||||
|
||||
# L10N command that affects a layer
|
||||
N_("ignore_layer"): N_("Ignore layer (do not stitch any objects in this layer)"),
|
||||
|
||||
|
|
@ -34,7 +38,7 @@ COMMANDS = {
|
|||
N_("stop_position"): N_("Jump destination for Stop commands (a.k.a. \"Frame Out position\")."),
|
||||
}
|
||||
|
||||
OBJECT_COMMANDS = ["fill_start", "fill_end", "stop", "trim", "ignore_object"]
|
||||
OBJECT_COMMANDS = ["fill_start", "fill_end", "stop", "trim", "ignore_object", "satin_cut_point"]
|
||||
LAYER_COMMANDS = ["ignore_layer"]
|
||||
GLOBAL_COMMANDS = ["origin", "stop_position"]
|
||||
|
||||
|
|
@ -101,6 +105,8 @@ class Command(BaseCommand):
|
|||
if neighbors[0][0].tag != SVG_USE_TAG:
|
||||
raise CommandParseError("connector does not point to a use tag")
|
||||
|
||||
self.use = neighbors[0][0]
|
||||
|
||||
self.symbol = self.get_node_by_url(neighbors[0][0].get(XLINK_HREF))
|
||||
self.parse_symbol()
|
||||
|
||||
|
|
|
|||
|
|
@ -247,6 +247,12 @@ class EmbroideryElement(object):
|
|||
|
||||
return [self.strip_control_points(subpath) for subpath in path]
|
||||
|
||||
def flatten_subpath(self, subpath):
|
||||
path = [deepcopy(subpath)]
|
||||
cspsubdiv(path, 0.1)
|
||||
|
||||
return self.strip_control_points(path[0])
|
||||
|
||||
@property
|
||||
def trim_after(self):
|
||||
return self.get_boolean_param('trim_after', False)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
from itertools import chain, izip
|
||||
from shapely import geometry as shgeo, ops as shops
|
||||
from copy import deepcopy
|
||||
from shapely import geometry as shgeo, affinity as shaffinity
|
||||
import cubicsuperpath
|
||||
|
||||
from .element import param, EmbroideryElement, Patch
|
||||
from ..i18n import _
|
||||
from ..utils import cache, Point
|
||||
from ..utils import cache, Point, cut
|
||||
from ..svg import line_strings_to_csp, get_correction_transform
|
||||
|
||||
|
||||
class SatinColumn(EmbroideryElement):
|
||||
|
|
@ -141,77 +144,167 @@ class SatinColumn(EmbroideryElement):
|
|||
|
||||
@property
|
||||
@cache
|
||||
def flattened_beziers(self):
|
||||
def rails(self):
|
||||
"""The rails in order, as LineStrings"""
|
||||
return [subpath for i, subpath in enumerate(self.csp) if i in self.rail_indices]
|
||||
|
||||
@property
|
||||
@cache
|
||||
def rungs(self):
|
||||
"""The rungs, as LineStrings.
|
||||
|
||||
If there are no rungs, then this is an old-style satin column. The
|
||||
rails are expected to have the same number of path nodes. The path
|
||||
nodes, taken in sequential pairs, act in the same way as rungs would.
|
||||
"""
|
||||
if len(self.csp) == 2:
|
||||
return self.simple_flatten_beziers()
|
||||
elif len(self.csp) < 2:
|
||||
self.fatal(_("satin column: %(id)s: at least two subpaths required (%(num)d found)") % dict(num=len(self.csp), id=self.node.get('id')))
|
||||
# It's an old-style satin column. To make things easier we'll
|
||||
# actually create the implied rungs.
|
||||
return self._synthesize_rungs()
|
||||
else:
|
||||
return self.flatten_beziers_with_rungs()
|
||||
return [subpath for i, subpath in enumerate(self.csp) if i not in self.rail_indices]
|
||||
|
||||
def flatten_beziers_with_rungs(self):
|
||||
input_paths = [self.flatten([path]) for path in self.csp]
|
||||
input_paths = [shgeo.LineString(path[0]) for path in input_paths]
|
||||
def _synthesize_rungs(self):
|
||||
rung_endpoints = []
|
||||
for rail in self.rails:
|
||||
points = self.strip_control_points(rail)
|
||||
|
||||
paths = input_paths[:]
|
||||
paths.sort(key=lambda path: path.length, reverse=True)
|
||||
# ignore the start and end
|
||||
points = points[1:-1]
|
||||
|
||||
rung_endpoints.append(points)
|
||||
|
||||
rungs = []
|
||||
for start, end in izip(*rung_endpoints):
|
||||
# Expand the points just a bit to ensure that shapely thinks they
|
||||
# intersect with the rails even with floating point inaccuracy.
|
||||
start = Point(*start)
|
||||
end = Point(*end)
|
||||
start, end = self.offset_points(start, end, 0.01)
|
||||
start = list(start)
|
||||
end = list(end)
|
||||
|
||||
rungs.append([[start, start, start], [end, end, end]])
|
||||
|
||||
return rungs
|
||||
|
||||
@property
|
||||
@cache
|
||||
def rail_indices(self):
|
||||
paths = [self.flatten_subpath(subpath) for subpath in self.csp]
|
||||
paths = [shgeo.LineString(path) for path in paths]
|
||||
num_paths = len(paths)
|
||||
|
||||
# Imagine a satin column as a curvy ladder.
|
||||
# The two long paths are the "rails" of the ladder. The remainder are
|
||||
# the "rungs".
|
||||
rails = paths[:2]
|
||||
rungs = shgeo.MultiLineString(paths[2:])
|
||||
#
|
||||
# The subpaths in this SVG path may be in arbitrary order, so we need
|
||||
# to figure out which are the rails and which are the rungs.
|
||||
#
|
||||
# Rungs are the paths that intersect with exactly 2 other paths.
|
||||
# Rails are everything else.
|
||||
|
||||
# The rails should stay in the order they were in the original CSP.
|
||||
# (this lets the user control where the satin starts and ends)
|
||||
rails.sort(key=lambda rail: input_paths.index(rail))
|
||||
if num_paths <= 2:
|
||||
# old-style satin column with no rungs
|
||||
return range(num_paths)
|
||||
|
||||
result = []
|
||||
# This takes advantage of the fact that sum() counts True as 1
|
||||
intersection_counts = [sum(paths[i].intersects(paths[j]) for j in xrange(num_paths) if i != j)
|
||||
for i in xrange(num_paths)]
|
||||
paths_not_intersecting_two = [i for i in xrange(num_paths) if intersection_counts[i] != 2]
|
||||
num_not_intersecting_two = len(paths_not_intersecting_two)
|
||||
|
||||
if num_not_intersecting_two == 2:
|
||||
# Great, we have two unambiguous rails.
|
||||
return paths_not_intersecting_two
|
||||
else:
|
||||
# This is one of two situations:
|
||||
#
|
||||
# 1. There are two rails and two rungs, and it looks like a
|
||||
# hash symbol (#). Unfortunately for us, this is an ambiguous situation
|
||||
# and we'll have to take a guess as to which are the rails and
|
||||
# which are the rungs. We'll guess that the rails are the longest
|
||||
# ones.
|
||||
#
|
||||
# or,
|
||||
#
|
||||
# 2. The paths don't look like a ladder at all, but some other
|
||||
# kind of weird thing. Maybe one of the rungs crosses a rail more
|
||||
# than once. Treat it like the previous case and we'll sort out
|
||||
# the intersection issues later.
|
||||
indices_by_length = sorted(range(num_paths), key=lambda index: paths[index].length, reverse=True)
|
||||
return indices_by_length[:2]
|
||||
|
||||
def _cut_rail(self, rail, rung):
|
||||
intersections = 0
|
||||
|
||||
for segment_index, rail_segment in enumerate(rail[:]):
|
||||
if rail_segment is None:
|
||||
continue
|
||||
|
||||
intersection = rail_segment.intersection(rung)
|
||||
|
||||
if not intersection.is_empty:
|
||||
if isinstance(intersection, shgeo.MultiLineString):
|
||||
intersections += len(intersection)
|
||||
break
|
||||
else:
|
||||
intersections += 1
|
||||
|
||||
cut_result = cut(rail_segment, rail_segment.project(intersection))
|
||||
rail[segment_index:segment_index + 1] = cut_result
|
||||
|
||||
if cut_result[1] is None:
|
||||
# if we were exactly at the end of one of the existing rail segments,
|
||||
# stop here or we'll get a spurious second intersection on the next
|
||||
# segment
|
||||
break
|
||||
|
||||
return intersections
|
||||
|
||||
@property
|
||||
@cache
|
||||
def flattened_sections(self):
|
||||
"""Flatten the rails, cut with the rungs, and return the sections in pairs."""
|
||||
|
||||
if len(self.csp) < 2:
|
||||
self.fatal(_("satin column: %(id)s: at least two subpaths required (%(num)d found)") % dict(num=len(self.csp), id=self.node.get('id')))
|
||||
|
||||
rails = [[shgeo.LineString(self.flatten_subpath(rail))] for rail in self.rails]
|
||||
rungs = [shgeo.LineString(self.flatten_subpath(rung)) for rung in self.rungs]
|
||||
|
||||
for rung in rungs:
|
||||
for rail_index, rail in enumerate(rails):
|
||||
intersections = self._cut_rail(rail, rung)
|
||||
|
||||
if intersections == 0:
|
||||
self.fatal(_("satin column: One or more of the rungs doesn't intersect both rails.") +
|
||||
" " + _("Each rail should intersect both rungs once."))
|
||||
elif intersections > 1:
|
||||
self.fatal(_("satin column: One or more of the rungs intersects the rails more than once.") +
|
||||
" " + _("Each rail should intersect both rungs once."))
|
||||
|
||||
for rail in rails:
|
||||
if not rail.is_simple:
|
||||
self.fatal(_("One or more rails crosses itself, and this is not allowed. Please split into multiple satin columns."))
|
||||
for i in xrange(len(rail)):
|
||||
if rail[i] is not None:
|
||||
rail[i] = [Point(*coord) for coord in rail[i].coords]
|
||||
|
||||
# handle null intersections here?
|
||||
linestrings = shops.split(rail, rungs)
|
||||
# Clean out empty segments. Consider an old-style satin like this:
|
||||
#
|
||||
# | |
|
||||
# * *---*
|
||||
# | |
|
||||
# | |
|
||||
#
|
||||
# The stars indicate where the bezier endpoints lay. On the left, there's a
|
||||
# zero-length bezier at the star. The user's goal here is to ignore the
|
||||
# horizontal section of the right rail.
|
||||
|
||||
# print >> dbg, "rails and rungs", [str(rail) for rail in rails], [str(rung) for rung in rungs]
|
||||
if len(linestrings.geoms) < len(rungs.geoms) + 1:
|
||||
self.fatal(_("satin column: One or more of the rungs doesn't intersect both rails.") +
|
||||
" " + _("Each rail should intersect both rungs once."))
|
||||
elif len(linestrings.geoms) > len(rungs.geoms) + 1:
|
||||
self.fatal(_("satin column: One or more of the rungs intersects the rails more than once.") +
|
||||
" " + _("Each rail should intersect both rungs once."))
|
||||
sections = zip(*rails)
|
||||
sections = [s for s in sections if s[0] is not None and s[1] is not None]
|
||||
|
||||
paths = [[Point(*coord) for coord in ls.coords] for ls in linestrings.geoms]
|
||||
result.append(paths)
|
||||
|
||||
return zip(*result)
|
||||
|
||||
def simple_flatten_beziers(self):
|
||||
# Given a pair of paths made up of bezier segments, flatten
|
||||
# each individual bezier segment into line segments that approximate
|
||||
# the curves. Retain the divisions between beziers -- we'll use those
|
||||
# later.
|
||||
|
||||
paths = []
|
||||
|
||||
for path in self.csp:
|
||||
# See the documentation in the parent class for parse_path() for a
|
||||
# description of the format of the CSP. Each bezier is constructed
|
||||
# using two neighboring 3-tuples in the list.
|
||||
|
||||
flattened_path = []
|
||||
|
||||
# iterate over pairs of 3-tuples
|
||||
for prev, current in zip(path[:-1], path[1:]):
|
||||
flattened_segment = self.flatten([[prev, current]])
|
||||
flattened_segment = [Point(x, y) for x, y in flattened_segment[0]]
|
||||
flattened_path.append(flattened_segment)
|
||||
|
||||
paths.append(flattened_path)
|
||||
|
||||
return zip(*paths)
|
||||
return sections
|
||||
|
||||
def validate_satin_column(self):
|
||||
# The node should have exactly two paths with no fill. Each
|
||||
|
|
@ -223,10 +316,120 @@ class SatinColumn(EmbroideryElement):
|
|||
if self.get_style("fill") is not None:
|
||||
self.fatal(_("satin column: object %s has a fill (but should not)") % node_id)
|
||||
|
||||
if len(self.csp) == 2:
|
||||
if len(self.csp[0]) != len(self.csp[1]):
|
||||
if not self.rungs:
|
||||
if len(self.rails[0]) != len(self.rails[1]):
|
||||
self.fatal(_("satin column: object %(id)s has two paths with an unequal number of points (%(length1)d and %(length2)d)") %
|
||||
dict(id=node_id, length1=len(self.csp[0]), length2=len(self.csp[1])))
|
||||
dict(id=node_id, length1=len(self.rails[0]), length2=len(self.rails[1])))
|
||||
|
||||
def split(self, split_point):
|
||||
"""Split a satin into two satins at the specified point
|
||||
|
||||
split_point is a point on or near one of the rails, not at one of the
|
||||
ends. Finds corresponding point on the other rail (taking into account
|
||||
the rungs) and breaks the rails at these points.
|
||||
|
||||
Returns two new SatinColumn instances: the part before and the part
|
||||
after the split point. All parameters are copied over to the new
|
||||
SatinColumn instances.
|
||||
"""
|
||||
|
||||
cut_points = self._find_cut_points(split_point)
|
||||
path_lists = self._cut_rails(cut_points)
|
||||
self._assign_rungs_to_split_rails(path_lists)
|
||||
self._add_rungs_if_necessary(path_lists)
|
||||
return self._path_lists_to_satins(path_lists)
|
||||
|
||||
def _find_cut_points(self, split_point):
|
||||
"""Find the points on each satin corresponding to the split point.
|
||||
|
||||
split_point is a point that is near but not necessarily touching one
|
||||
of the rails. It is projected onto that rail to obtain the cut point
|
||||
for that rail. A corresponding cut point will be chosen on the other
|
||||
rail, taking into account the satin's rungs to choose a matching point.
|
||||
|
||||
Returns: a list of two Point objects corresponding to the selected
|
||||
cut points.
|
||||
"""
|
||||
|
||||
split_point = Point(*split_point)
|
||||
patch = self.do_satin()
|
||||
index_of_closest_stitch = min(range(len(patch)), key=lambda index: split_point.distance(patch.stitches[index]))
|
||||
|
||||
if index_of_closest_stitch % 2 == 0:
|
||||
# split point is on the first rail
|
||||
return (patch.stitches[index_of_closest_stitch],
|
||||
patch.stitches[index_of_closest_stitch + 1])
|
||||
else:
|
||||
# split point is on the second rail
|
||||
return (patch.stitches[index_of_closest_stitch - 1],
|
||||
patch.stitches[index_of_closest_stitch])
|
||||
|
||||
def _cut_rails(self, cut_points):
|
||||
"""Cut the rails of this satin at the specified points.
|
||||
|
||||
cut_points is a list of two elements, corresponding to the cut points
|
||||
for each rail in order.
|
||||
|
||||
Returns: A list of two elements, corresponding two the two new sets of
|
||||
rails. Each element is a list of two rails of type LineString.
|
||||
"""
|
||||
|
||||
rails = [shgeo.LineString(self.flatten_subpath(rail)) for rail in self.rails]
|
||||
|
||||
path_lists = [[], []]
|
||||
|
||||
for i, rail in enumerate(rails):
|
||||
before, after = cut(rail, rail.project(shgeo.Point(cut_points[i])))
|
||||
path_lists[0].append(before)
|
||||
path_lists[1].append(after)
|
||||
|
||||
return path_lists
|
||||
|
||||
def _assign_rungs_to_split_rails(self, split_rails):
|
||||
"""Add this satin's rungs to the new satins.
|
||||
|
||||
Each rung is appended to the correct one of the two new satin columns.
|
||||
"""
|
||||
|
||||
rungs = [shgeo.LineString(self.flatten_subpath(rung)) for rung in self.rungs]
|
||||
for path_list in split_rails:
|
||||
path_list.extend(rung for rung in rungs if path_list[0].intersects(rung) and path_list[1].intersects(rung))
|
||||
|
||||
def _add_rungs_if_necessary(self, path_lists):
|
||||
"""Add an additional rung to each new satin if it ended up with none.
|
||||
|
||||
If the split point is between the end and the last rung, then one of
|
||||
the satins will have no rungs. Add one to make it stitch properly.
|
||||
"""
|
||||
|
||||
# no need to add rungs if there weren't any in the first place
|
||||
if not self.rungs:
|
||||
return
|
||||
|
||||
for path_list in path_lists:
|
||||
if len(path_list) == 2:
|
||||
# If a path has no rungs, it may be invalid. Add a rung at the start.
|
||||
rung_start = path_list[0].interpolate(0.1)
|
||||
rung_end = path_list[1].interpolate(0.1)
|
||||
rung = shgeo.LineString((rung_start, rung_end))
|
||||
|
||||
# make it a bit bigger so that it definitely intersects
|
||||
rung = shaffinity.scale(rung, 1.1, 1.1)
|
||||
|
||||
path_list.append(rung)
|
||||
|
||||
def _path_lists_to_satins(self, path_lists):
|
||||
transform = get_correction_transform(self.node)
|
||||
satins = []
|
||||
for path_list in path_lists:
|
||||
node = deepcopy(self.node)
|
||||
csp = line_strings_to_csp(path_list)
|
||||
d = cubicsuperpath.formatPath(csp)
|
||||
node.set("d", d)
|
||||
node.set("transform", transform)
|
||||
satins.append(SatinColumn(node))
|
||||
|
||||
return satins
|
||||
|
||||
def offset_points(self, pos1, pos2, offset_px):
|
||||
# Expand or contract two points about their midpoint. This is
|
||||
|
|
@ -300,7 +503,7 @@ class SatinColumn(EmbroideryElement):
|
|||
remainder_path1 = []
|
||||
remainder_path2 = []
|
||||
|
||||
for segment1, segment2 in self.flattened_beziers:
|
||||
for segment1, segment2 in self.flattened_sections:
|
||||
subpath1 = remainder_path1 + segment1
|
||||
subpath2 = remainder_path2 + segment2
|
||||
|
||||
|
|
@ -410,7 +613,7 @@ class SatinColumn(EmbroideryElement):
|
|||
# zigzag looks like this to make the satin stitches look perpendicular
|
||||
# to the column:
|
||||
#
|
||||
# /|/|/|/|/|/|/|/|
|
||||
# |/|/|/|/|/|/|/|/|
|
||||
|
||||
# print >> dbg, "satin", self.zigzag_spacing, self.pull_compensation
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ from object_commands import ObjectCommands
|
|||
from layer_commands import LayerCommands
|
||||
from global_commands import GlobalCommands
|
||||
from convert_to_satin import ConvertToSatin
|
||||
from cut_satin import CutSatin
|
||||
|
||||
__all__ = extensions = [Embroider,
|
||||
Install,
|
||||
|
|
@ -24,4 +25,5 @@ __all__ = extensions = [Embroider,
|
|||
ObjectCommands,
|
||||
LayerCommands,
|
||||
GlobalCommands,
|
||||
ConvertToSatin]
|
||||
ConvertToSatin,
|
||||
CutSatin]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
import inkex
|
||||
|
||||
from .base import InkstitchExtension
|
||||
from ..i18n import _
|
||||
from ..elements import SatinColumn
|
||||
|
||||
|
||||
class CutSatin(InkstitchExtension):
|
||||
def effect(self):
|
||||
if not self.get_elements():
|
||||
return
|
||||
|
||||
if not self.selected:
|
||||
inkex.errormsg(_("Please select one or more satin columns to cut."))
|
||||
return
|
||||
|
||||
for satin in self.elements:
|
||||
if isinstance(satin, SatinColumn):
|
||||
command = satin.get_command("satin_cut_point")
|
||||
|
||||
if command is None:
|
||||
# L10N will have the satin's id prepended, like this:
|
||||
# path12345: error: this satin column does not ...
|
||||
satin.fatal(_('this satin column does not have a "satin column cut point" command attached to it. '
|
||||
'Please use the "Attach commands" extension and attach the "Satin Column cut point" command first.'))
|
||||
|
||||
split_point = command.target_point
|
||||
command.use.getparent().remove(command.use)
|
||||
command.connector.getparent().remove(command.connector)
|
||||
|
||||
new_satins = satin.split(split_point)
|
||||
parent = satin.node.getparent()
|
||||
index = parent.index(satin.node)
|
||||
parent.remove(satin.node)
|
||||
for new_satin in new_satins:
|
||||
parent.insert(index, new_satin.node)
|
||||
index += 1
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
import inkex
|
||||
import cubicsuperpath
|
||||
from shapely import geometry as shgeo
|
||||
|
||||
from .base import InkstitchExtension
|
||||
from ..i18n import _
|
||||
|
|
@ -8,21 +7,11 @@ from ..elements import SatinColumn
|
|||
|
||||
|
||||
class Flip(InkstitchExtension):
|
||||
def subpath_to_linestring(self, subpath):
|
||||
return shgeo.LineString()
|
||||
|
||||
def flip(self, satin):
|
||||
csp = satin.path
|
||||
|
||||
if len(csp) > 1:
|
||||
flattened = satin.flatten(csp)
|
||||
|
||||
# find the rails (the two longest paths) and swap them
|
||||
indices = range(len(csp))
|
||||
indices.sort(key=lambda i: shgeo.LineString(flattened[i]).length, reverse=True)
|
||||
|
||||
first = indices[0]
|
||||
second = indices[1]
|
||||
first, second = satin.rail_indices
|
||||
csp[first], csp[second] = csp[second], csp[first]
|
||||
|
||||
satin.node.set("d", cubicsuperpath.formatPath(csp))
|
||||
|
|
|
|||
|
|
@ -485,9 +485,9 @@ def connect_points(shape, start, end, running_stitch_length, row_spacing):
|
|||
# up at 12 again.
|
||||
result = cut(outline, start_projection)
|
||||
|
||||
# result will be None if our starting point happens to already be at
|
||||
# result[0] will be None if our starting point happens to already be at
|
||||
# 12 o'clock.
|
||||
if result is not None and result[1] is not None:
|
||||
if result[0] is not None:
|
||||
before, after = result
|
||||
|
||||
# Make a new outline, starting from the starting point. This is
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
from .svg import color_block_to_point_lists, render_stitch_plan
|
||||
from .units import *
|
||||
from .path import apply_transforms, get_node_transform, get_correction_transform
|
||||
from .path import apply_transforms, get_node_transform, get_correction_transform, line_strings_to_csp
|
||||
|
|
|
|||
|
|
@ -47,3 +47,16 @@ def get_correction_transform(node, child=False):
|
|||
transform = simpletransform.invertTransform(transform)
|
||||
|
||||
return simpletransform.formatTransform(transform)
|
||||
|
||||
|
||||
def line_strings_to_csp(line_strings):
|
||||
csp = []
|
||||
|
||||
for ls in line_strings:
|
||||
subpath = []
|
||||
for point in ls.coords:
|
||||
# create a straight line as a degenerate bezier
|
||||
subpath.append((point, point, point))
|
||||
csp.append(subpath)
|
||||
|
||||
return csp
|
||||
|
|
|
|||
|
|
@ -7,8 +7,11 @@ def cut(line, distance):
|
|||
|
||||
This is an example in the Shapely documentation.
|
||||
"""
|
||||
if distance <= 0.0 or distance >= line.length:
|
||||
return [LineString(line), None]
|
||||
if distance <= 0.0:
|
||||
return [None, line]
|
||||
elif distance >= line.length:
|
||||
return [line, None]
|
||||
|
||||
coords = list(ShapelyPoint(p) for p in line.coords)
|
||||
traveled = 0
|
||||
last_point = coords[0]
|
||||
|
|
@ -88,6 +91,9 @@ class Point:
|
|||
def length(self):
|
||||
return math.sqrt(math.pow(self.x, 2.0) + math.pow(self.y, 2.0))
|
||||
|
||||
def distance(self, other):
|
||||
return (other - self).length()
|
||||
|
||||
def unit(self):
|
||||
return self.mul(1.0 / self.length())
|
||||
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
Przed Szerokość: | Wysokość: | Rozmiar: 34 KiB Po Szerokość: | Wysokość: | Rozmiar: 39 KiB |
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
|
||||
<name>{% trans %}Cut Satin Column{% endtrans %}</name>
|
||||
<id>org.inkstitch.cut_satin.{{ locale }}</id>
|
||||
<dependency type="executable" location="extensions">inkstitch.py</dependency>
|
||||
<dependency type="executable" location="extensions">inkex.py</dependency>
|
||||
<param name="extension" type="string" gui-hidden="true">cut_satin</param>
|
||||
<effect>
|
||||
<object-type>all</object-type>
|
||||
<effects-menu>
|
||||
<submenu name="Ink/Stitch">
|
||||
<submenu name="{% trans %}English{% endtrans %}" />
|
||||
</submenu>
|
||||
</effects-menu>
|
||||
</effect>
|
||||
<script>
|
||||
<command reldir="extensions" interpreter="python">inkstitch.py</command>
|
||||
</script>
|
||||
</inkscape-extension>
|
||||
|
|
@ -248,115 +248,114 @@ msgstr ""
|
|||
msgid "shape is not valid. This can happen if the border crosses over itself."
|
||||
msgstr ""
|
||||
|
||||
#: lib/elements/satin_column.py:10
|
||||
msgid "Satin Column"
|
||||
msgstr ""
|
||||
|
||||
#: lib/elements/satin_column.py:16
|
||||
#: lib/elements/satin_column.py:19
|
||||
msgid "Custom satin column"
|
||||
msgstr ""
|
||||
|
||||
#: lib/elements/satin_column.py:22
|
||||
#: lib/elements/satin_column.py:25
|
||||
msgid "\"E\" stitch"
|
||||
msgstr ""
|
||||
|
||||
#: lib/elements/satin_column.py:32 lib/elements/stroke.py:55
|
||||
#: lib/elements/satin_column.py:35 lib/elements/stroke.py:55
|
||||
msgid "Zig-zag spacing (peak-to-peak)"
|
||||
msgstr ""
|
||||
|
||||
#: lib/elements/satin_column.py:33
|
||||
#: lib/elements/satin_column.py:36
|
||||
msgid "Peak-to-peak distance between zig-zags."
|
||||
msgstr ""
|
||||
|
||||
#: lib/elements/satin_column.py:44
|
||||
#: lib/elements/satin_column.py:47
|
||||
msgid "Pull compensation"
|
||||
msgstr ""
|
||||
|
||||
#: lib/elements/satin_column.py:45
|
||||
#: lib/elements/satin_column.py:48
|
||||
msgid "Satin stitches pull the fabric together, resulting in a column narrower than you draw in Inkscape. This setting expands each pair of needle penetrations outward from the center of the satin column."
|
||||
msgstr ""
|
||||
|
||||
#: lib/elements/satin_column.py:57
|
||||
#: lib/elements/satin_column.py:60
|
||||
msgid "Contour underlay"
|
||||
msgstr ""
|
||||
|
||||
#: lib/elements/satin_column.py:57 lib/elements/satin_column.py:64
|
||||
#: lib/elements/satin_column.py:73
|
||||
#: lib/elements/satin_column.py:60 lib/elements/satin_column.py:67
|
||||
#: lib/elements/satin_column.py:76
|
||||
msgid "Contour Underlay"
|
||||
msgstr ""
|
||||
|
||||
#: lib/elements/satin_column.py:64 lib/elements/satin_column.py:88
|
||||
#: lib/elements/satin_column.py:67 lib/elements/satin_column.py:91
|
||||
msgid "Stitch length"
|
||||
msgstr ""
|
||||
|
||||
#: lib/elements/satin_column.py:70
|
||||
#: lib/elements/satin_column.py:73
|
||||
msgid "Contour underlay inset amount"
|
||||
msgstr ""
|
||||
|
||||
#: lib/elements/satin_column.py:71
|
||||
#: lib/elements/satin_column.py:74
|
||||
msgid "Shrink the outline, to prevent the underlay from showing around the outside of the satin column."
|
||||
msgstr ""
|
||||
|
||||
#: lib/elements/satin_column.py:81
|
||||
#: lib/elements/satin_column.py:84
|
||||
msgid "Center-walk underlay"
|
||||
msgstr ""
|
||||
|
||||
#: lib/elements/satin_column.py:81 lib/elements/satin_column.py:88
|
||||
#: lib/elements/satin_column.py:84 lib/elements/satin_column.py:91
|
||||
msgid "Center-Walk Underlay"
|
||||
msgstr ""
|
||||
|
||||
#: lib/elements/satin_column.py:93
|
||||
#: lib/elements/satin_column.py:96
|
||||
msgid "Zig-zag underlay"
|
||||
msgstr ""
|
||||
|
||||
#: lib/elements/satin_column.py:93 lib/elements/satin_column.py:102
|
||||
#: lib/elements/satin_column.py:113
|
||||
#: lib/elements/satin_column.py:96 lib/elements/satin_column.py:105
|
||||
#: lib/elements/satin_column.py:116
|
||||
msgid "Zig-zag Underlay"
|
||||
msgstr ""
|
||||
|
||||
#: lib/elements/satin_column.py:99
|
||||
#: lib/elements/satin_column.py:102
|
||||
msgid "Zig-Zag spacing (peak-to-peak)"
|
||||
msgstr ""
|
||||
|
||||
#: lib/elements/satin_column.py:100
|
||||
#: lib/elements/satin_column.py:103
|
||||
msgid "Distance between peaks of the zig-zags."
|
||||
msgstr ""
|
||||
|
||||
#: lib/elements/satin_column.py:110
|
||||
#: lib/elements/satin_column.py:113
|
||||
msgid "Inset amount"
|
||||
msgstr ""
|
||||
|
||||
#: lib/elements/satin_column.py:111
|
||||
#: lib/elements/satin_column.py:114
|
||||
msgid "default: half of contour underlay inset"
|
||||
msgstr ""
|
||||
|
||||
#: lib/elements/satin_column.py:148
|
||||
#: lib/elements/satin_column.py:249
|
||||
#, python-format
|
||||
msgid "satin column: %(id)s: at least two subpaths required (%(num)d found)"
|
||||
msgstr ""
|
||||
|
||||
#: lib/elements/satin_column.py:173
|
||||
#: lib/elements/satin_column.py:257
|
||||
msgid "One or more rails crosses itself, and this is not allowed. Please split into multiple satin columns."
|
||||
msgstr ""
|
||||
|
||||
#: lib/elements/satin_column.py:180
|
||||
#: lib/elements/satin_column.py:264
|
||||
msgid "satin column: One or more of the rungs doesn't intersect both rails."
|
||||
msgstr ""
|
||||
|
||||
#: lib/elements/satin_column.py:181 lib/elements/satin_column.py:184
|
||||
#: lib/elements/satin_column.py:265 lib/elements/satin_column.py:268
|
||||
msgid "Each rail should intersect both rungs once."
|
||||
msgstr ""
|
||||
|
||||
#: lib/elements/satin_column.py:183
|
||||
#: lib/elements/satin_column.py:267
|
||||
msgid "satin column: One or more of the rungs intersects the rails more than once."
|
||||
msgstr ""
|
||||
|
||||
#: lib/elements/satin_column.py:224
|
||||
#: lib/elements/satin_column.py:283
|
||||
#, python-format
|
||||
msgid "satin column: object %s has a fill (but should not)"
|
||||
msgstr ""
|
||||
|
||||
#: lib/elements/satin_column.py:228
|
||||
#: lib/elements/satin_column.py:287
|
||||
#, python-format
|
||||
msgid "satin column: object %(id)s has two paths with an unequal number of points (%(length1)d and %(length2)d)"
|
||||
msgstr ""
|
||||
|
|
@ -406,6 +405,10 @@ msgid "Legacy running stitch setting detected!\n\n"
|
|||
"It looks like you're using a stroke smaller than 0.5 units to indicate a running stitch, which is deprecated. Instead, please set your stroke to be dashed to indicate running stitch. Any kind of dash will work."
|
||||
msgstr ""
|
||||
|
||||
#: lib/extensions/auto_satin.py:14
|
||||
msgid "Please select one or more satin columns to operate on."
|
||||
msgstr ""
|
||||
|
||||
#: lib/extensions/base.py:113
|
||||
msgid "No embroiderable paths selected."
|
||||
msgstr ""
|
||||
|
|
@ -438,7 +441,7 @@ msgid "\n\n"
|
|||
"Seeing a 'no such option' message? Please restart Inkscape to fix."
|
||||
msgstr ""
|
||||
|
||||
#: lib/extensions/flip.py:35
|
||||
#: lib/extensions/flip.py:25
|
||||
msgid "Please select one or more satin columns to flip."
|
||||
msgstr ""
|
||||
|
||||
|
|
@ -1162,21 +1165,25 @@ msgstr ""
|
|||
msgid "Brother Stitch Format"
|
||||
msgstr ""
|
||||
|
||||
#: templates/convert_to_satin.inx:3
|
||||
msgid "Convert Line to Satin"
|
||||
#: templates/auto_satin.inx:3
|
||||
msgid "Auto Satin"
|
||||
msgstr ""
|
||||
|
||||
#. This is used for the submenu under Extensions -> Ink/Stitch. Translate this
|
||||
#. to your language's word for its language, e.g. "Español" for the spanish
|
||||
#. translation.
|
||||
#: templates/convert_to_satin.inx:12 templates/embroider.inx:24
|
||||
#: templates/flip.inx:12 templates/global_commands.inx:16
|
||||
#: templates/install.inx:12 templates/layer_commands.inx:16
|
||||
#: templates/object_commands.inx:15 templates/params.inx:12
|
||||
#: templates/print.inx:12 templates/simulate.inx:12
|
||||
#: templates/auto_satin.inx:12 templates/convert_to_satin.inx:12
|
||||
#: templates/embroider.inx:24 templates/flip.inx:12
|
||||
#: templates/global_commands.inx:16 templates/install.inx:12
|
||||
#: templates/layer_commands.inx:16 templates/object_commands.inx:15
|
||||
#: templates/params.inx:12 templates/print.inx:12 templates/simulate.inx:12
|
||||
msgid "English"
|
||||
msgstr ""
|
||||
|
||||
#: templates/convert_to_satin.inx:3
|
||||
msgid "Convert Line to Satin"
|
||||
msgstr ""
|
||||
|
||||
#: templates/embroider.inx:3
|
||||
msgid "Embroider"
|
||||
msgstr ""
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue