66import vpype as vp
77
88# Load the default config
9- from vpype import LayerType
109
1110vp .CONFIG_MANAGER .load_config_file (str (Path (__file__ ).parent / "bundled_configs.toml" ))
1211
1312
14- def invert_axis (
15- document : vp .Document ,
16- invert_x : bool ,
17- invert_y : bool
18- ):
19- """ Inverts none, one or borth axis of the document.
13+ def invert_axis (document : vp .Document , invert_x : bool , invert_y : bool ):
14+ """Inverts none, one or both axis of the document.
2015 This applies a relative scale operation with factors of 1 or -1
21- on the two axis to all layers. The invertion happens relative to
16+ on the two axis to all layers. The inversion happens relative to
2217 the center of the bounds.
2318 """
2419
25- layer_ids = vp .multiple_to_layer_ids (LayerType .ALL , document )
26- bounds = document .bounds (layer_ids )
27-
20+ bounds = document .bounds ()
2821 if not bounds :
2922 return document
3023
@@ -33,14 +26,13 @@ def invert_axis(
3326 0.5 * (bounds [1 ] + bounds [3 ]),
3427 )
3528
36- for vid in layer_ids :
37- lc = document [vid ]
38- lc .translate (- origin [0 ], - origin [1 ])
39- lc .scale (- 1 if invert_x else 1 , - 1 if invert_y else 1 )
40- lc .translate (origin [0 ], origin [1 ])
29+ document .translate (- origin [0 ], - origin [1 ])
30+ document .scale (- 1 if invert_x else 1 , - 1 if invert_y else 1 )
31+ document .translate (origin [0 ], origin [1 ])
4132
4233 return document
4334
35+
4436@click .command ()
4537@click .argument ("output" , type = click .File ("w" ))
4638@click .option (
0 commit comments