pull/219/head
Lex Neva 2018-07-07 15:31:59 -04:00
rodzic 8c009e381e
commit ac84d7b0d4
1 zmienionych plików z 8 dodań i 2 usunięć
lib/extensions

Wyświetl plik

@ -1,19 +1,25 @@
import sys
import inkex
import cubicsuperpath
from shapely import geometry as shgeo
from .base import InkstitchExtension
from ..i18n import _
from ..elements import SatinColumn
class Flip(InkstitchExtension):
def subpath_to_linestring(self, subpath):
return shgeo.LineString()
def flip(self, satin):
csp = cubicsuperpath.parsePath(satin.node.get("d"))
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: len(csp[i]), reverse=True)
indices.sort(key=lambda i: shgeo.LineString(flattened[i]).length, reverse=True)
first = indices[0]
second = indices[1]