Copy link to clipboard
Copied
Hello,
I have been running into this problem a lot during my workflow. I often need to reflect a selection on both axis, and the only way to do it is to manually reflect it on one axis, and then go through the process again for the other.
Does anyone know of any script that could solve this issue for me?
another similar way
app.selection[0].resize(-100,-100);
Copy link to clipboard
Copied
You could create an action that does both quite easily, unless you specifically need a script.
Copy link to clipboard
Copied
I have actually managed to find a script that does this. Leaving the code here, as it may help someone else in the future:
mySelection = activeDocument.selection;
if (mySelection.length>0){
var doc = app.activeDocument; //current document
var s = doc.selection; //current slection
var sl = s.length; //number of selected objects
var m = app.getScaleMatrix(-100,-100); //H flip matrix - feel free to change to (100,-100) for vertical flip, etc.
for(var i = 0 ; i < sl; i++) s[i].transform(m); //for each selected element apply the flip matrix
app.redraw();
}else{
alert("Nothing selected!")
}
mySelection = activeDocument.selection;
if (mySelection.length>0){
var doc = app.activeDocument; //current document
var s = doc.selection; //current slection
var sl = s.length; //number of selected objects
var m = app.getScaleMatrix(-100,-100); //H flip matrix
for(var i = 0 ; i < sl; i++) s[i].transform(m); //for each selected element apply the flip matrix
app.redraw();
}else{
alert("Nothing selected!")
}
Copy link to clipboard
Copied
An alternative approach (you can choose reflecting around either the X or Y-axis by deleting the reciprocal of the two last lines):
// select item
var item = app.activeDocument.selection[0];
function reflectY(item) {
var m = new Matrix();
m.mValueA = -1;
m.mValueB = 0;
m.mValueC = 0;
m.mValueD = 1;
item.transform(m);
}
function reflectX(item) {
var m = new Matrix();
m.mValueA = 1;
m.mValueB = 0;
m.mValueC = 0;
m.mValueD = -1;
item.transform(m);
}
reflectY(item);
reflectX(item);
Copy link to clipboard
Copied
another similar way
app.selection[0].resize(-100,-100);