零点参考线、缩放选定图层、透明像素裁切
This commit is contained in:
1 parent
58155f32d6
commit
6a800280d4
3 files changed
+175
No files matched your search
@@ -0,0 +1,51 @@
|
||||
#target photoshop
|
||||
|
||||
/*
|
||||
Create missing guides at the document origin.
|
||||
Existing guides at X=0 or Y=0 are not duplicated.
|
||||
*/
|
||||
|
||||
(function () {
|
||||
if (app.documents.length === 0) {
|
||||
alert("请先打开一个文档。");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
var document = app.activeDocument;
|
||||
var hasVerticalAtZero = false;
|
||||
var hasHorizontalAtZero = false;
|
||||
var tolerance = 0.001;
|
||||
var i;
|
||||
|
||||
for (i = 0; i < document.guides.length; i++) {
|
||||
var guide = document.guides[i];
|
||||
var position = guide.coordinate.as("px");
|
||||
|
||||
if (Math.abs(position) <= tolerance) {
|
||||
if (guide.direction === Direction.VERTICAL) {
|
||||
hasVerticalAtZero = true;
|
||||
} else if (guide.direction === Direction.HORIZONTAL) {
|
||||
hasHorizontalAtZero = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasVerticalAtZero) {
|
||||
document.guides.add(
|
||||
Direction.VERTICAL,
|
||||
new UnitValue(0, "px")
|
||||
);
|
||||
}
|
||||
|
||||
if (!hasHorizontalAtZero) {
|
||||
document.guides.add(
|
||||
Direction.HORIZONTAL,
|
||||
new UnitValue(0, "px")
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
alert("创建参考线失败:\n" + error.message);
|
||||
}
|
||||
}());
|
||||
|
||||
Reference in new issue
Block a user