-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSqueeze Frame - Horizontal - Out.js
More file actions
56 lines (45 loc) · 1.53 KB
/
Copy pathSqueeze Frame - Horizontal - Out.js
File metadata and controls
56 lines (45 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// ----------- Squeeze Frame - Horizonal - Out ----------- //
/*
DECREASES the horizontal width of a text frame by equal amounts on both sides.
One part of a series of scripts, meant to be used together:
- Squeeze Frame - Horizontal - In.js
->> Squeeze Frame - Horizontal - Out.js
- Squeeze Frame - Vertical - In.js
- Squeeze Frame - Vertical - Out.js
Most Common Use Case:
- As I typeset, I want to incrementally adjust the horizontal width of a text
frame so that the text reflows into a diamond shape.
Updated: October 19 2021, Sara Linsley
*/
var squeezeFactor = -0.05; // change this number to increase/decrease the amount the text frame is squeezed by
var doc = app.activeDocument;
function main() {
var hasErrors = false,
selections = app.selection;
for (var i = 0; i < selections.length && !hasErrors; i++) {
var textFrame = selections[i];
hasErrors = isError(textFrame);
if (!hasErrors) {
squeezeHoriz(textFrame, squeezeFactor);
};
}
}
function isError(obj) {
if (!(obj instanceof TextFrame)) {
alert('Please select some text frames and try again');
return true;
}
return false;
}
function transformCoords(src, trns) {
return [
src[0] + trns[0],
src[1] + trns[1],
src[2] + trns[2],
src[3] + trns[3]
];
}
function squeezeHoriz(srcObj, by) {
srcObj.geometricBounds = transformCoords(srcObj.geometricBounds, [0, by, 0, by * -1]);
}
main();