如何在basil.js中剪切/裁剪图像并复制

How cut/crop an image and duplicate it in basil.js

本文关键字:裁剪 图像 复制 basil js      更新时间:2023-09-26

我正试图在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();

有人知道如何使用basils .js或java代码吗?由于

裁判:https://i.stack.imgur.com/qwWmK.jpg

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

#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();