Monday, November 9, 2015 InDesign,Extendscript

Draw Bézier Curve

Try to draw bezier curve in InDesign with Extendscript.

A bezier.js script result is below.

bézier result

It is a little difficult for me to draw bezier curve by extendscript.

At first draw plan how to do by hand like this...

bézier planning

If in android , maybe code like this.

path.moveTo ( B.x,B.y )
path.cubicTo( C.x,C.y, D.x,D.y, E.x,E.y )

But, I do not know why, InDesign needs three points by ONE anchor point.

  • use A,B,C for B anchor point
  • use D,E,F for E anchor point

A part of extendscript ...

var pointA = [20,100];
var pointB = [30,60];
var pointC = [40,20];

var pointD = [60,20];
var pointE = [70,60];
var pointF = [80,100];

var entirePath = [];
entirePath.push( [pointA, pointB, pointC] );
entirePath.push( [pointD, pointE, pointF] );

polygon.paths[0].properties = {
    entirePath: entirePath,
    pathType:   PathType.OPEN_PATH

More details ... bezier.js