summaryrefslogtreecommitdiff
path: root/lib/extensions/flip.py
blob: 87b8b3f0c2f67113c784cd1f5243581ffd2edd0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import inkex

from ..elements import SatinColumn
from ..i18n import _
from .base import InkstitchExtension


class Flip(InkstitchExtension):
    def flip(self, satin):
        csp = satin.path

        if len(csp) > 1:
            first, second = satin.rail_indices
            csp[first], csp[second] = csp[second], csp[first]

            satin.node.set("d", inkex.paths.CubicSuperPath.to_path(csp))

    def effect(self):
        if not self.get_elements():
            return

        if not self.svg.selected:
            inkex.errormsg(_("Please select one or more satin columns to flip."))
            return

        for element in self.elements:
            if isinstance(element, SatinColumn):
                self.flip(element)