0

我正在尝试在 basil.js 中编写一个脚本来复制图像并剪切/裁剪框架内的图像。在 basil.js 参考(http://basiljs.ch/reference/)中,我没有找到在 Indesign 框架内移动图像的功能。

#includepath "~/Documents/;%USERPROFILE%Documents";
#include "basiljs/bundle/basil.js";

function draw() {

    for(var n=0; n<800; n+=100){
        for (var c=0; c<800; c+=100){
        var img = b.image('image-example.jpg', n, c, 100, 100);
        }
    }

}

b.go();

任何人都知道如何使用 basil.js 或 java 代码做到这一点?谢谢

参考:http: //i.stack.imgur.com/qwWmK.jpg

4

1 回答 1

0

尝试像这样放置图像并在矩形内移动其内部位置:

#includepath "~/Documents/;%USERPROFILE%Documents";
#include "basiljs/bundle/basil.js";

function draw() {
  var frame = b.rect(0,0,300,100);
  var imgFile = new File("/Users/bene/Desktop/image.jpg");
  frame.place(imgFile);
  // optional FitOptions e.g.
  frame.fit( FitOptions.FILL_PROPORTIONALLY );
  frame.fit( FitOptions.CENTER_CONTENT );

  // print current inner position
  b.println( frame.allGraphics[0].geometricBounds );

  // change inner pos
  var x = 100;
  var y = 50;
  var bounds = frame.allGraphics[0].geometricBounds;
  frame.allGraphics[0].geometricBounds = [y, x, bounds[2], bounds[3]];

  // print new inner pos
  b.println( frame.allGraphics[0].geometricBounds );
}

b.go();
于 2014-05-20T14:41:14.150 回答