def effect(self): for node in self.svg.selected.values(): min_bbox_angle = rotate_helper.optimal_rotations(node)[1] if min_bbox_angle is not None: node.transform = Transform( rotate_helper.rotate_matrix( node, min_bbox_angle)) * node.transform
def effect(self): def duplicateNodes(aList): clones = {} for id, node in aList.items(): clone = copy.deepcopy(node) #!!!--> should it be given an id? #seems to work without this!?! myid = node.tag.split('}')[-1] clone.set("id", self.svg.get_unique_id(myid)) node.getparent().append(clone) clones[clone.get("id")] = clone return (clones) for nid, node in self.svg.selected.items(): # set() removes duplicates angles = set( # and remove Nones [ x for x in rotate_helper.optimal_rotations(node) if x is not None ]) # Go backwards so we know if we need to duplicate the node for # multiple rotations. (We don't want to rotate the main node # before duplicating it.) for i, angle in reversed(list(enumerate(angles))): if i > 0: # Rotate a duplicate of the node rotate_node = list(duplicateNodes({ nid: node }).items())[0][1] else: rotate_node = node rotate_node.transform = rotate_helper.rotate_matrix( rotate_node, angle) * rotate_node.transform
def effect(self): pm = PathModifier() pm.document = self.document for nid, node in self.selected.iteritems(): # set() removes duplicates angles = set( # and remove Nones [x for x in rotate_helper.optimal_rotations(node) if x is not None]) # Go backwards so we know if we need to duplicate the node for # multiple rotations. (We don't want to rotate the main node # before duplicating it.) for i, angle in reversed(list(enumerate(angles))): if i > 0: # Rotate a duplicate of the node rotate_node = pm.duplicateNodes({nid: node}).items()[0][1] else: rotate_node = node simpletransform.applyTransformToNode( rotate_helper.rotate_matrix(rotate_node, angle), rotate_node)
def effect(self): for node in self.selected.values(): min_width_angle = rotate_helper.optimal_rotations(node)[0] if min_width_angle is not None: simpletransform.applyTransformToNode( rotate_helper.rotate_matrix(node, min_width_angle), node)