论坛帮助 |
社区圈子 |
日历事件 |
2019-12-10, 20:42 | #1 | ||
|
|||
正式会员
等级: 四袋长老
|
还有求助一下,有没有把对象改随机大小的脚本,保持比例 doc = app.activeDocument; sel = doc.selection; first = 1; ang = 0; for(i=0; i<sel.length; i++) { if(sel[i].typename == "GroupItem" || sel[i].typename == "PathItem" || sel[i].typename == "CompoundPathItem") { currGroup = sel[i]; getFP = FindFirstPath(currGroup); currpath = getFP[1]; if(getFP[0] == 1) { p1 = currpath.pathPoints[0].anchor; p2 = currpath.pathPoints[1].anchor; deltax = p1[0]-p2[0]; deltay = p1[1]-p2[1]; currang = Math.atan(deltay/deltax); if(deltax<0) currang+=Math.PI; if(first) { first = 0; ang = currang; } else { currGroup.rotate((ang-currang)*180/Math.PI); } } } } function FindFirstPath(workGroup) { if(workGroup.typename == "PathItem") return [1, workGroup]; if(workGroup.typename == "CompoundPathItem") return [1, workGroup.pathItems[0]]; nSubPathes = workGroup.pathItems.length; if(nSubPathes > 0) return [1, workGroup.pathItems[0]]; nSubPathes = workGroup.compoundPathItems.length; if(nSubPathes > 0) return [1, workGroup.compoundPathItems[0].pathItems[0]]; nSubGroups = workGroup.groupItems.length; if(nSubGroups==0) return [0, 0]; var currRet = [0, 0]; for(iGroup=0; iGroup<nSubGroups; iGroup++) { currRet = FindFirstPath(workGroup.groupItems[iGroup]); if(currRet[0]==1) break; } return currRet; } |
||
2019-12-11, 08:42 | 只看该作者 #2 | |||
|
||||
VIP会员
等级: 七袋长老
|
引用:
aDoc = app.activeDocument; aSel = aDoc.selection; nSel = aSel.length; opMin = Number(prompt("最小缩小比 (0-1000%)", 0)); opMax = Number(prompt("最大放大比 (0-1000%)", 200)); if(opMin > opMax) { temp = opMin; opMin = opMax; opMax = temp; } if(opMin<0) opMIn = 0; if(opMax>1000) opMax = 1000; for(i=0; i<nSel; i++) { resScale = Math.floor(Math.random() * (opMax - opMin + 1)) + opMin; aSel[i].resize(resScale, resScale); } //(END)随机缩放/////////////////////////////////////////////////////////// //随机不透明度/////////////////////////////////////////////////////////// aDoc = app.activeDocument; aSel = aDoc.selection; nSel = aSel.length; opMin = Number(prompt("最小不透明度 (0-100)", 0)); opMax = Number(prompt("最大不透明度 (0-100)", 100)); if(opMin > opMax) { temp = opMin; opMin = opMax; opMax = temp; } if(opMin<0) opMIn = 0; if(opMax>100) opMax = 100; for(i=0; i<nSel; i++) { aSel[i].opacity = Math.floor(Math.random() * (opMax - opMin + 1)) + opMin; } //(END)随机不透明度/////////////////////////////////////////////////////////// //随机旋转/////////////////////////////////////////////////////////// aDoc = app.activeDocument; aSel = aDoc.selection; nSel = aSel.length; opMin = Number(prompt("最小旋转角度 (0-180)", 0)); opMax = Number(prompt("最大旋转角度 (180-360)", 360)); if(opMin > opMax) { temp = opMin; opMin = opMax; opMax = temp; } if(opMin<0) opMIn = 0; if(opMax>1000) opMax = 1000; for(i=0; i<nSel; i++) { resRotate = Math.floor(Math.random() * (opMax - opMin + 1)) + opMin; aSel[i].rotate(resRotate, resRotate); } //(END)随机旋转/////////////////////////////////////////////////////////// |
|||
右列会员因为此帖价值甚高向 calvin530126 表示感谢: |
songzongsen (2019-12-11)
|
2019-12-11, 08:51 | 只看该作者 #3 | ||
|
|||
正式会员
等级: 四袋长老
|
引用:
|
||