【问题标题】:Drawing a Line in InDesign CS5.5 using ExtendScript在 InDesign CS5.5 中使用 ExtendScript 绘制线条
【发布时间】:2016-01-16 22:01:12
【问题描述】:

我想知道如何使用类似的扩展脚本在 InDesign 上画一条线

伪代码

for(x = 0; x < 5; x++){
    drawLine(The X Value to startLine, The Y-Value to startLine, Length, Color);
}

任何帮助将不胜感激。

谢谢

【问题讨论】:

    标签: extendscript


    【解决方案1】:

    试试这个脚本。 https://github.com/fabiantheblind/extendscript/wiki/Graphic-Lines

    var data = {
            "pw":100,
            "ph":100,
            "anchors":[
                [  0,50],
                [ 10,60],
                [ 20,40],
                [ 30,60],
                [ 40,40],
                [ 50,60],
                [ 60,40],
                [ 70,60],
                [ 80,40],
                [ 90,60],
                [100,50]
            ]
        };
    // We need a doc.
    // Use pw and ph from data.
    var doc = app.documents.add({
                documentPreferences:{
                    pageHeight:data.ph,
                    pageWidth:data.pw
                }
        }); 
    // The page is already there.
    var page = doc.pages.item(0);
    // Create a graphicLine.
    var gl = page.graphicLines.add(); 
    // Loop through the data.anchors.
    for(var i in data.anchors){
        var point = gl.paths[0].pathPoints[i];
        /**
         * a graphicLine always has 2 path points
         * so we need to add points only from the third
         * anchor from the data object
         */
        if(i < 2){
            point.anchor = data.anchors[i];
        }else{
            point = gl.paths[0].pathPoints.add();
            point.anchor =  data.anchors[i];
         }
             if((i != data.anchors.length - 1)&& i!=0)
            point.rightDirection = data.anchors[i-1];
            point.leftDirection = data.anchors[i];
        } 
    

    【讨论】:

      猜你喜欢
      • 2021-11-26
      • 2021-11-15
      • 1970-01-01
      • 2017-10-29
      • 2023-02-12
      • 2013-05-12
      • 1970-01-01
      • 2012-05-13
      • 2017-09-28
      相关资源
      最近更新 更多