From ac84d7b0d4365b61b5a375b8c4497a81093cc734 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Sat, 7 Jul 2018 15:31:59 -0400 Subject: [PATCH] fix brain-o --- lib/extensions/flip.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/extensions/flip.py b/lib/extensions/flip.py index 75d8fe175..d8d78cb54 100644 --- a/lib/extensions/flip.py +++ b/lib/extensions/flip.py @@ -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]