Copy link to clipboard
Copied
I am looking to achieve this result with a group or many items. The scaling should happen along a direction and if possible radial too. The objects can be randomly arranged too. I need the scaling to follow from high to low.
Copy link to clipboard
Copied
Bonjour,
Essayez cela.
// JavaScript Document for illustrator
// reduire via direction
// Auteur Landry René
function main() {
var item, pathes = [];
extractPathes(selection,pathes);
if (pathes.length == 0) {
alert("Une sélection est obligatoire ?");
return;
}
var pos = [];
for (var h = 0; h < pathes.length; h++) {
item = pathes[h];
pos.push([item.top-item.height/2,pathes[h]])
}
pos.sort(function (a, b) { return a[0]-b[0]} )
var nbr = 0;
var top0 = pos[0][0];
do {
nbr++;
}
while (pos[nbr][0] > top0-5 && pos[nbr][0]< top0+5)
var nbl = pos.length/nbr;
var ecart = 100/(nbl+1);
//alert( pos.join("\r"))
var r = 100-ecart;
var top0 = pos[nbr-1][0];
for(var h = nbr, c = 0; h < pos.length; h++) {
top = pos[h][0];
if (pos[h][0] > top0+5) {
pos[h][1].resize(r,r);
c++;
}
if (c == nbr) {top0 = pos[h][0]; r -= ecart; c = 0;}
}
}
main();
// --------
function extractPathes(s, tabs){
for(var i = 0; i < s.length; i++){
if(s[i].typename == "PathItem" && !s[i].guides && !s[i].clipping){
tabs.push(s[i]);
} else if(s[i].typename == "GroupItem"){
// Cherche les objets de types pageItems dans ce groupe, recursivement
extractPathes(s[i].pageItems, tabs);
} else if(s[i].typename == "CompoundPathItem"){
// Cherche les objets de type PathItem dans ce trace transparent, recursivement
extractPathes(s[i].pathItems, tabs);
}
}
}
// --------
Copy link to clipboard
Copied
That works very well, René.
Thanks for sharing.
Copy link to clipboard
Copied
This works with well arranged object.
I applied random positions to my object and it didn't worked. See Test.ai file https://t.ly/Tnv0z
Can we also get a gradient annotator style tool for this so that I can scale it as per my direction. Further if there is a scale intensity option too, it will be great.
Copy link to clipboard
Copied
Bonjour StartAG
Le script fonctionne avec de objets alignés horizontalement avec une tolérance de +- 5pt,
désolé, je pensais que votre exemple correspondait à ça (je l'ai édité spécialement pour l'occasion).
Je constate que vous êtes assez exigeant.
René