def on_menu_vertical_flip(self, event): page = self.main_notebook.GetCurrentPage() if not isinstance(page, EmbroideryView) or page.emb_pattern is None: return pattern = page.emb_pattern m = pyembroidery.EmbMatrix() m.post_scale(1, -1) pattern.transform(m) page.on_size(None)
def on_menu_rotate_ccw(self, event): page = self.main_notebook.GetCurrentPage() if not isinstance(page, EmbroideryView) or page.emb_pattern is None: return pattern = page.emb_pattern m = pyembroidery.EmbMatrix() m.post_rotate(-90) pattern.transform(m) page.on_size(None)
def on_menu_reduce(self, event): page = self.main_notebook.GetCurrentPage() if not isinstance(page, EmbroideryView) or page.emb_pattern is None: return pattern = page.emb_pattern m = pyembroidery.EmbMatrix() m.post_scale(0.9, 0.9) pattern.transform(m) page.on_size(None) page.update_drawing()
def command_translate(self, values): x = self.v() y = self.v() if x is not None: x = float(x) if y is not None: y = float(y) matrix = pyembroidery.EmbMatrix() matrix.post_translate(x, y) for value in values: if not isinstance(value, tuple): continue pattern = value[0] pattern.transform(matrix) self.log("Transformed", pattern, "by", x, y) return values
def command_rotate(self, values): theta = self.v() x = self.v() y = self.v() if theta is not None: theta = float(theta) if x is not None: x = float(x) if y is not None: y = float(y) matrix = pyembroidery.EmbMatrix() matrix.post_rotate(theta, x, y) for value in values: if not isinstance(value, tuple): continue pattern = value[0] pattern.transform(matrix) self.log("Rotated", pattern, "by", theta, "degrees.") return values
def command_scale(self, values): sx = self.v() sy = self.v() x = self.v() y = self.v() if sx is not None: sx = float(sx) if sy is not None: sy = float(sy) if x is not None: x = float(x) if y is not None: y = float(y) matrix = pyembroidery.EmbMatrix() matrix.post_scale(sx, sy, x, y) for value in values: if not isinstance(value, tuple): continue pattern = value[0] pattern.transform(matrix) self.log("Scaled", pattern, "by", sx, sy) return values